Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 阻断屏的定时兜底只在前台敲门
guyongf9a5107586ea
diff --git a/apps/mobile/src/__tests__/forcedUpdateGate.test.ts b/apps/mobile/src/__tests__/forcedUpdateGate.test.tsindex ed02f6b920..e7b1637662 100644--- a/apps/mobile/src/__tests__/forcedUpdateGate.test.ts+++ b/apps/mobile/src/__tests__/forcedUpdateGate.test.ts@@ -79,6 +79,8 @@ describe('强更阻断闸门', () => {const recheckHook = readCode('src/update/useForcedUpdateRecheck.ts');expect(recheckHook).toContain('rechecker.handleTick()');expect(recheckHook).toContain('clearInterval(timer)');+ // 但兜底只在前台敲门:后台定时器仍可能触发,那会白发 /latest(耗电 + 后台网络)。+ expect(recheckHook).toContain("if (AppState.currentState !== 'active') return;");// 在途期间若有更新的观察写入 store,本次旧结论必须作废(compare-and-set)。expect(recheck).toContain('const startRevision = deps.getRevision?.();');expect(recheck).toContain('deps.onCleared(startRevision)');diff --git a/apps/mobile/src/update/useForcedUpdateRecheck.ts b/apps/mobile/src/update/useForcedUpdateRecheck.tsindex 43e98df83d..d6d69b2d59 100644--- a/apps/mobile/src/update/useForcedUpdateRecheck.ts+++ b/apps/mobile/src/update/useForcedUpdateRecheck.ts@@ -54,6 +54,10 @@ export function useForcedUpdateRecheck(isCanary = isCanaryChannel()): void {// 而在后台被置位又在节流窗口内回前台的那次 'active' 也会被节流丢掉。// 实际请求频率由核对器内部节流(默认 30s)决定,这里只负责按时敲门。const timer = setInterval(() => {+ // 只在前台敲门:部分平台 / 配置下定时器在后台仍会触发,那会白发 /latest+ // (耗电 + 无谓的后台网络)。回前台那一刻由 AppState 通道负责,+ // 定时兜底只需要覆盖"用户停在前台的阻断屏上、没有任何跳变"这一种场景。+ if (AppState.currentState !== 'active') return;void rechecker.handleTick();}, RECHECK_TICK_MS);return () => {