Repository navigation
fix(agy): use local quota snapshots and disable refresh for non-current accounts in Auth Center - #10073
Conversation
20a1496 to
db24eaf
Compare
farion1231
left a comment
There was a problem hiding this comment.
感谢!维护者决定授权中心的非当前 Antigravity 账号采用本 PR 的方案:直接显示本地快照,↻ 置灰并加悬停提示。db24eaff 补的回焦同步也解决了从外部终端切号回来后,真正在用的号还被置灰的问题。
main 已经合入了 12602dd(授权中心和绑号官方卡在点非当前号的 ↻ 后弹 toast),和本 PR 在 AccountQuota.tsx 和八个语言文件上有冲突,需要 rebase 到最新的 main。解冲突时请注意:
- 授权中心以本 PR 为准:
AgyAccountQuota里 12602dd 加的 toast 和refreshHint那套去掉,保留置灰方案。QuotaRefreshCell两边都加了悬停提示参数(main 叫hint,本 PR 也有对应的 prop),合成一个就行。 authCenter.agy.quotaRefreshNotCurrent不要改文案:main 上AgyAccountQuotaFooter.tsx(供应商卡片)的 toast 还在用这个 key 的长句。置灰按钮的悬停提示请另起一个新 key,八个语言文件同步加上。- 供应商卡片那边保持 main 现状,本 PR 不用动。
另外一个小建议(不阻塞):removeAgyNotFoundQuotas 里的 removeQueries 会让仍在观察这个查询的组件和缓存断开,紧接着的 invalidateQueries 不会让它重新查询,要等组件下次重新渲染。授权中心的行会重新挂载,所以不受影响;绑号官方卡在自动模式下通过「打开终端」切到一个没有快照的号时,可能会一直空着。换成 resetQueries 就能避免,CurrentAgyAccountQuota 里 cachedNotFound 那层保护也可以一起去掉。
db24eaf to
d0ee28c
Compare
|
@farion1231 已按意见 rebase 到最新
全部前后端检查均已重新跑过并通过( |
…nt accounts in Auth Center
d0ee28c to
7ca66cf
Compare
|
已合并,感谢您的贡献!rebase 处理得很干净,key 拆分和 |
Resolve conflicts with the Antigravity quota rework that landed on main (farion1231#10073 local quota snapshots, farion1231#10056 tray respects manual-only quota, farion1231#10062 failure reuse and Windows CLI checks, 12602dd non-current refresh hint). Main already lets non-current accounts show their saved snapshot without starting agy and honours the "auto-query quota" switch, so the quota side of this branch is resolved in main's favour: the forced manual-only `manual` flag on agy_account_quota / get_subscription_quota, the switching/login guard that only served it, and the manual-refresh epoch on the frontend are dropped. Desktop sync, the running-state block, the card switch button and the re-login fixes are kept as they were. Also drops the unused runningNoticeTitle/runningNoticeBody strings and main's has_agy_in_tasklist, which this branch's tasklist parser replaces.
Human Note / 本人说明
在 v4.0.44 授权中心把 agy 从一个账号切到另一个账号时,看到旧账号切走后还留着之前查到的历史额度和可以点的
↻刷新按钮,容易让人误以为还能实时查最新额度;如果关掉了「自动查询额度」,非当前号会显示「点刷新查询额度」,点过一次无快照的非当前号再切到那个号,整列额度连同右侧↻按钮还会直接消失,而且页头点「全部刷新」也会连非当前 agy 账号一起扫去读钥匙串,在外部终端切号回来「agy 在用」徽标也不会马上刷新。这个 PR 只聚焦修授权中心里非当前 agy 账号的只读快照展示、置灰禁用刷新按钮与悬停提示,以及切号/全部刷新/回焦同步这几处问题,保持当前号在关闭自动查询模式下的「点刷新查询额度 ↻」现状,不动供应商卡片、托盘、WorkBuddy 和数据库版本。Summary / 概述
Fix Auth Center quota UX and state bugs for non-current Antigravity (
agy) accounts introduced after v4.0.44 switched quota fetching toagy --print /usage:1. Pure-local snapshot read path for non-current accounts (Backend + API)
agy_account_last_quota(accountId)insrc-tauri/src/commands/agy_account.rsand register it insrc-tauri/src/lib.rs, backed directly byAgyAccountManager::last_quota(zero keychain/usr/bin/securitycalls, zeroagysubprocess launches, zero network requests).subscriptionApi.getAgyAccountLastQuota(src/lib/api/subscription.ts) anduseAgyAccountLastQuota(src/lib/query/subscription.ts) with query key["agy_oauth", "last_quota", accountId].2. Auth Center non-current vs current Antigravity quota UX (
AccountQuota.tsx)AccountQuotaColumnwith optionalrefreshDisabledandrefreshHintprops, forwarded toQuotaRefreshCell(disabledandhint), preserving the↻slot for column alignment while settingaria-disabled(withcursor-not-allowed, muted styling, no-op click) and customHoverTiptext.AgyAccountQuotaintoNonCurrentAgyAccountQuotaandCurrentAgyAccountQuota:useAgyAccountLastQuotadirectly regardless ofofficialQuotaManualOnly, showing the stored historical bars and truequeriedAtrelative time as-is; when no valid local snapshot exists, render"切到这个号后才能查额度"instead of misleading"点刷新查询额度"; right-side↻is muted/disabled with hover tooltip"切到这个号后才能查最新额度"(authCenter.agy.quotaRefreshDisabledHint), keepingauthCenter.agy.quotaRefreshNotCurrentintact forAgyAccountQuotaFooter.tsx.agy 在用): keeps existing"点刷新查询额度 ↻"behavior underofficialQuotaManualOnly: true(does not overlap with [Feature] 授权中心所有官方服务统一持久化并展示上次刷新的额度、套餐与查询时间 #10057) and delegatesnot_foundcache clearing toresetAgyNotFoundQuotaswithout extracachedNotFoundstate inCurrentAgyAccountQuota.3. Switch invalidation, Refresh All, and window-focus login sync
invalidateAgyLoginCaches(src/lib/query/subscription.ts) resets cachednot_foundentries from["agy_oauth", "quota"]viaqueryClient.resetQueries(resetAgyNotFoundQuotas, preserving active observers such as mounted bound provider cards in auto mode instead of detaching them viaremoveQueries), awaitsagyAuthStatusQueryinvalidation first, and then invalidates non-current["agy_oauth", "quota", *]withrefetchType: "none"(actively refetching only the current account) so the displaced account never triggers a redundantagy_account_quotakeychain read before React unmounts it, alongside invalidating["agy_oauth", "last_quota"].RefreshAllQuotaButton(src/components/settings/auth/RefreshAllQuotaButton.tsx) skips non-currentagy_oauthquota queries when auth status is known (in addition to non-current rows no longer mountinguseAgyAccountQuota), avoiding redundant serial keychain reads.subscribeWindowFocusinsrc/lib/windowActivity.ts(reusing the deduplicated DOMfocus+ TaurionFocusChangedactive transitions sincefocusManagerintentionally stays focused for visible unfocused windows) andsyncAgyLoginOnWindowFocusinsrc/lib/query/subscription.ts, wired inuseManagedAuth("agy_oauth")alongsiderefetchOnWindowFocus: "always"onagyAuthStatusQuery. Returning to the window after switching accounts in an external terminal immediately refreshes"agy 在用"and invalidates quota caches only whendefault_account_idactually changed. Completingagy_oauthlogin/reauth polling inuseManagedAuthalso invokesinvalidateAgyQuotaCachesso newly signed-in or re-authenticated accounts reset any prior cachednot_foundstate and refresh cleanly.4. Internationalization & Tests
authCenter.agy.quotaRefreshDisabledHintacross all 8 locale files (zh,zh-TW,en,de,ja,ko,ru,tr; leavingauthCenter.agy.quotaRefreshNotCurrentuntouched forAgyAccountQuotaFooter.tsx; non-Chinese/English translations were reviewed for consistency withquotaNotCurrent).src-tauri/src/services/agy_account/tests.rsverifyinglast_quotareads snapshots with 0 keychain reads even when locked.tests/components/AgyAccountQuota.test.tsx(14 cases, includingresetQuerieskeeping mounted auto-mode observers connected without refetching non-currentnot_foundobservers),tests/hooks/useManagedAuth.test.tsx(window-focus refresh, external switch invalidation, andagy_oauthlogin-polling cache invalidation), andtests/lib/windowActivity.test.ts(visible blur-to-focus deduplication), plus default MSW handler intests/msw/handlers.ts.Scope boundary
AgyAccountQuotaFooter(provider cards), tray menu/panel, WorkBuddy, or databaseSCHEMA_VERSION.Related Issue / 关联 Issue
Fixes #10072
Screenshots / 截图
↻;手动模式下显示「点刷新查询额度」,点过无快照非当前号再切过去后整列额度与↻消失↻置灰禁用并悬停提示「切到这个号后才能查最新额度」;切号后当前号正常保留↻Checklist / 检查清单
pnpm typecheckpasses / 通过 TypeScript 类型检查pnpm format:checkpasses / 通过代码格式检查(同时通过pnpm knip、pnpm build:renderer、pnpm test:unit348/348 files, 4605/4605 tests)cargo clippypasses (if Rust code changed) / 通过 Clippy 检查(同时通过cargo fmt --check、cargo test --lib services::agy_account32/32 及cargo test --test integration231/231)