Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): TestFlight 跳过整包更新并明确检查范围 (#489) (#575)
qsoyq5f039486d9ab
diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsxindex fd5cef823a..8191619493 100644--- a/apps/mobile/app/_layout.tsx+++ b/apps/mobile/app/_layout.tsx@@ -153,11 +153,11 @@ function RootAfterUpdateChannel({ isCanary }: { isCanary: boolean }) {useEffect(() => {if (otaReady) dispatchHandoff({ type: 'ota-ready' });}, [otaReady, dispatchHandoff]);- // 自建变体:启动时检查整包更新(runtimeVersion 变化 → 引导跳 NPKG)。- // 内部 IS_OTA_SELFHOST gate,EAS 包为 no-op。JS 热更由上面的门 + expo-updates 处理,与此互补。+ // 符合整包分发策略的自建变体:启动时检查整包更新(runtimeVersion 变化 → 引导安装)。+ // TestFlight / 审核 / EAS 包为 no-op。JS 热更由上面的门 + expo-updates 处理,与此互补。useBundleUpdatePrompt({ auto: true, isCanary });// 自建变体:后台切回前台时静默补一次检查(OTA 静默 fetch 不 reload、整包仅强更提示)。- // 内部节流 + IS_OTA_SELFHOST gate,非自建为 no-op。见 useResumeUpdateCheck。+ // TestFlight 保留 OTA、跳过整包分支;非自建为 no-op。见 useResumeUpdateCheck。useResumeUpdateCheck(isCanary);// 热更门未就绪(自建变体冷启动正在 check/fetch/reload)时不挂载业务树,避免闪旧 UI;// 期间根部常驻 splash 覆盖层在上面顶着,这里返回 null 即可。diff --git a/apps/mobile/app/settings.tsx b/apps/mobile/app/settings.tsxindex 006da9f3f3..3a8b52a9cc 100644--- a/apps/mobile/app/settings.tsx+++ b/apps/mobile/app/settings.tsx@@ -39,7 +39,15 @@ import {ScreenHeader,StatusDot,} from '@/components/MobilePrimitives';-import { AUTH_API_BASE_URL, AUTH_REGION, DESKTOP_PACKAGE_VERSION, DEVICE_LINK_API_BASE_URL, IS_OTA_SELFHOST, REVIEW_MODE } from '@/config/env';+import {+ AUTH_API_BASE_URL,+ AUTH_REGION,+ DESKTOP_PACKAGE_VERSION,+ DEVICE_LINK_API_BASE_URL,+ IS_OTA_SELFHOST,+ IS_TESTFLIGHT_BUILD,+ REVIEW_MODE,+} from '@/config/env';import { LEGAL_LINKS } from '@/config/legalLinks';import { useDeviceLink } from '@/device-link/DeviceLinkContext';import { buildMobileDeviceName } from '@/device-link/mobileDeviceIdentity';@@ -56,6 +64,7 @@ import {writePushEnabled,} from '@/notifications/pushNotifications';import { buildMobileUpdateInfoRows, currentMobileOtaVersion } from '@/settings/updateInfo';+import { shouldCheckBundleUpdate } from '@/update/bundleUpdate';import { runManualUpdateCheck } from '@/update/manualUpdateCheck';import { useBundleUpdatePrompt } from '@/update/useBundleUpdatePrompt';import { useCanaryChannelGate } from '@/update/useCanaryChannelGate';@@ -139,12 +148,17 @@ export default function SettingsScreen() {const updateInfoRows = useMemo(() => buildMobileUpdateInfoRows(currentlyRunning), [currentlyRunning, t]);const otaVersion = useMemo(() => currentMobileOtaVersion(currentlyRunning), [currentlyRunning, t]);const canaryChannel = useCanaryChannelGate(IS_OTA_SELFHOST);- // 自建变体的统一入口先查整包;无整包时再由 checkForUpdate 继续查 JS OTA。+ // 允许整包分发时统一入口先查整包;TestFlight 等禁用整包的环境直接进入 JS OTA。const { checkNow: checkBundleUpdate } = useBundleUpdatePrompt({auto: false,isCanary: canaryChannel.isCanary,});- const updateCheckEnabled = IS_OTA_SELFHOST || updatesEnabled;+ const bundleCheckEnabled = shouldCheckBundleUpdate({+ isSelfHosted: IS_OTA_SELFHOST,+ isReviewMode: REVIEW_MODE,+ isTestFlightBuild: IS_TESTFLIGHT_BUILD,+ });+ const updateCheckEnabled = bundleCheckEnabled || updatesEnabled;const aboutSection = overview.sections.find((section) => section.id === 'about');const debugSection = overview.sections.find((section) => section.id === 'debug');@@ -217,7 +231,7 @@ export default function SettingsScreen() {setUpdateMessage(null);try {const outcome = await runManualUpdateCheck({- checkBundleUpdate: IS_OTA_SELFHOST ? checkBundleUpdate : undefined,+ checkBundleUpdate: bundleCheckEnabled ? checkBundleUpdate : undefined,otaEnabled: updatesEnabled,checkOtaUpdate: () => Updates.checkForUpdateAsync(),fetchOtaUpdate: () => Updates.fetchUpdateAsync(),@@ -229,10 +243,18 @@ export default function SettingsScreen() {setUpdateMessage(t('settings.version.bundleUpdateFound'));} else if (outcome.kind === 'up-to-date') {setUpdatePhase('uptodate');- setUpdateMessage(t('settings.version.upToDate'));+ setUpdateMessage(t(+ IS_TESTFLIGHT_BUILD+ ? 'settings.version.testFlightNoContentUpdate'+ : 'settings.version.upToDate',+ ));} else if (outcome.kind === 'ota-unavailable') {setUpdatePhase('uptodate');- setUpdateMessage(t('settings.version.bundleUpToDateNoOta'));+ setUpdateMessage(t(+ IS_TESTFLIGHT_BUILD+ ? 'settings.version.testFlightContentUpdateUnavailable'+ : 'settings.version.bundleUpToDateNoOta',+ ));} else if (outcome.kind === 'reloading') {setUpdatePhase('downloading');setUpdateMessage(t('settings.version.downloadedRestarting'));@@ -245,7 +267,7 @@ export default function SettingsScreen() {} finally {updateCheckInFlightRef.current = false;}- }, [checkBundleUpdate, t, updateCheckEnabled, updatesEnabled]);+ }, [bundleCheckEnabled, checkBundleUpdate, t, updateCheckEnabled, updatesEnabled]);const updateSelfDeviceNameDraft = useCallback((value: string) => {selfDeviceNameDraftRef.current = value;@@ -560,7 +582,11 @@ export default function SettingsScreen() {const updateBusy = updatePhase === 'checking' || updatePhase === 'downloading';const updateButtonLabel = updatePhase === 'checking' ? t('settings.version.checking'): updatePhase === 'downloading' ? t('settings.version.updating')- : t('settings.version.checkAction');+ : t(+ IS_TESTFLIGHT_BUILD+ ? 'settings.version.testFlightCheckAction'+ : 'settings.version.checkAction',+ );if (selfDeviceNameEditing) {return (@@ -607,7 +633,7 @@ export default function SettingsScreen() {</View></View>- {/* 版本:只保留统一检查入口,自建线严格先查整包、无整包再查热更。 */}+ {/* 版本:只保留统一检查入口;允许整包分发时先查整包,否则直接查热更。 */}<SettingsGroup title={t('settings.version.sectionTitle')}>{[<View key="version" style={styles.versionRow} testID="settings.version">@@ -619,17 +645,38 @@ export default function SettingsScreen() {{IS_OTA_SELFHOST && DESKTOP_PACKAGE_VERSION ? (<Text style={styles.rowDetail} numberOfLines={1} testID="settings.desktopVersion">{t('settings.version.desktopVersion', { version: DESKTOP_PACKAGE_VERSION })}</Text>) : null}+ {IS_TESTFLIGHT_BUILD ? (+ <Text style={styles.rowDetail} numberOfLines={2} testID="settings.testFlightUpdateHint">+ {t('settings.version.testFlightUpdateManaged')}+ </Text>+ ) : null}{updateMessage ? (<Text style={styles.rowDetail} numberOfLines={2} testID="settings.updateMessage">{updateMessage}</Text>) : !REVIEW_MODE && !updatesEnabled ? (- <Text style={styles.rowDetail} numberOfLines={1}>{t('settings.version.devNoOta')}</Text>+ <Text style={styles.rowDetail} numberOfLines={2}>+ {t(+ IS_TESTFLIGHT_BUILD+ ? 'settings.version.testFlightContentUpdateUnavailable'+ : 'settings.version.devNoOta',+ )}+ </Text>) : null}</View>{/* 审核模式(清单 review 命中当前二进制版本):隐藏检查更新入口,版本号照常展示 */}{!REVIEW_MODE ? (<MainWindowActionButtonaction={{- accessibilityLabel: updateBusy ? t('settings.version.checkingAccessibility') : t('settings.version.checkAction'),+ accessibilityLabel: updateBusy+ ? t(+ IS_TESTFLIGHT_BUILD+ ? 'settings.version.testFlightCheckingAccessibility'+ : 'settings.version.checkingAccessibility',+ )+ : t(+ IS_TESTFLIGHT_BUILD+ ? 'settings.version.testFlightCheckAction'+ : 'settings.version.checkAction',+ ),busy: updateBusy,disabled: !updateCheckEnabled,label: updateButtonLabel,diff --git a/apps/mobile/src/__tests__/iosAppDistribution.test.ts b/apps/mobile/src/__tests__/iosAppDistribution.test.tsindex a9b0345e6c..ae4a1e4ed7 100644--- a/apps/mobile/src/__tests__/iosAppDistribution.test.ts+++ b/apps/mobile/src/__tests__/iosAppDistribution.test.ts@@ -75,6 +75,18 @@ describe('iOS app distribution Expo module', () => {resolve(process.cwd(), 'src/config/useStartupEndpointGate.ts'),'utf8',);+ const startupBundleCheck = readFileSync(+ resolve(process.cwd(), 'src/update/useBundleUpdatePrompt.ts'),+ 'utf8',+ );+ const resumeUpdateCheck = readFileSync(+ resolve(process.cwd(), 'src/update/useResumeUpdateCheck.ts'),+ 'utf8',+ );+ const settings = readFileSync(+ resolve(process.cwd(), 'app/settings.tsx'),+ 'utf8',+ );expect(swift).toContain('try await AppTransaction.shared');expect(swift).toContain('case .verified(let transaction)');@@ -85,5 +97,10 @@ describe('iOS app distribution Expo module', () => {// The async StoreKit lookup must complete inside the endpoint gate, before// REVIEW_MODE is consumed by any update hook or settings screen.expect(endpointGate).toContain('resolveIsTestFlight: isTestFlightBuild');+ // Startup, settings, and resume must all consume the resolved TestFlight+ // state before deciding whether the full-package channel is available.+ for (const source of [startupBundleCheck, settings, resumeUpdateCheck]) {+ expect(source).toContain('isTestFlightBuild: IS_TESTFLIGHT_BUILD');+ }});});diff --git a/apps/mobile/src/__tests__/mobileSettings.test.ts b/apps/mobile/src/__tests__/mobileSettings.test.tsindex c5b8247021..14b5266c13 100644--- a/apps/mobile/src/__tests__/mobileSettings.test.ts+++ b/apps/mobile/src/__tests__/mobileSettings.test.ts@@ -201,14 +201,22 @@ describe('mobile settings overview', () => {expect(accountActionsIndex).toBeGreaterThan(filingNumberIndex);});- it('keeps one update action and shows both full-package and OTA versions', () => {+ it('keeps one update action, scopes TestFlight checks to OTA, and shows both versions', () => {const source = readTextLf(resolve(process.cwd(), 'app/settings.tsx'), 'utf8');expect(source.match(/testID: 'settings\.checkUpdateButton'/g)).toHaveLength(1);expect(source).not.toContain('settings.checkBundleUpdateButton');expect(source).not.toContain('testID="settings.bundleUpdate"');expect(source).toContain('runManualUpdateCheck({');- expect(source).toContain('checkBundleUpdate: IS_OTA_SELFHOST ? checkBundleUpdate : undefined');+ expect(source).toContain('isTestFlightBuild: IS_TESTFLIGHT_BUILD');+ expect(source).toContain('const updateCheckEnabled = bundleCheckEnabled || updatesEnabled');+ expect(source).toContain('checkBundleUpdate: bundleCheckEnabled ? checkBundleUpdate : undefined');+ expect(source).toContain("'settings.version.testFlightCheckAction'");+ expect(source).toContain("'settings.version.testFlightCheckingAccessibility'");+ expect(source).toContain("'settings.version.testFlightNoContentUpdate'");+ expect(source).toContain("'settings.version.testFlightContentUpdateUnavailable'");+ expect(source).toContain("testID=\"settings.testFlightUpdateHint\"");+ expect(source).toContain("{t('settings.version.testFlightUpdateManaged')}");expect(source).toContain("{t('settings.version.bundleVersion', { version: appVersion })}");expect(source).toContain("testID=\"settings.otaVersion\">{t('settings.version.otaVersion', { version: otaVersion })}",diff --git a/apps/mobile/src/config/env.ts b/apps/mobile/src/config/env.tsindex 1b95a07101..503d3cb1cf 100644--- a/apps/mobile/src/config/env.ts+++ b/apps/mobile/src/config/env.ts@@ -240,8 +240,8 @@ export function isReviewModeActive(// 手机版审核模式(清单可选字段 review = 送审版本号,缺失/空串 = 关闭):App 审核// 期间线上清单填送审构建的二进制版本号,仅版本命中且 StoreKit 未识别为 TestFlight-// 的构建关闭全部 JS 显式更新检查(TestFlight 始终保留更新能力)-// (启动 JS 热更门 / 整包检查 / resume 静默检查)、设置页隐藏统一「检查更新」入口;+// 的构建关闭全部 JS 显式更新检查。TestFlight 不进入审核模式,但由整包更新策略单独+// 禁用会外跳安装的整包检查,只保留 JS OTA。设置页在审核模式隐藏统一「检查更新」入口;// 存量其它版本用户不受影响。覆盖边界与运维义务(原生层后台检查管不到、// 过审发布后须清空字段)见 maker-shared clientEndpoints 的 CLIENT_ENDPOINT_REVIEW_KEY// 注释。live binding:prod 由启动闸门回填,闸门 ready 前业务树不挂载,消费点@@ -249,7 +249,7 @@ export function isReviewModeActive(// desktop 忽略该字段。let resolvedReviewVersion = DEV_MANIFEST_PARSED?.reviewVersion ?? null;-/** StoreKit 在 endpoint 闸门期间识别出的 TestFlight 状态;供 JS 层同步诊断。 */+/** StoreKit 在 endpoint 闸门期间识别出的 TestFlight 状态;供更新策略与诊断同步消费。 */export let IS_TESTFLIGHT_BUILD = false;export let REVIEW_MODE = isReviewModeActive(@@ -286,7 +286,7 @@ export function applyResolvedClientEndpoints(resolved: {mobileUpdateBaseUrl?: string;/** 审核模式送审版本号(parser 产出,null = 清单未填;undefined = 不改动)。 */reviewVersion?: string | null;- /** iOS StoreKit 分发环境;TestFlight 必须继续检查更新。 */+ /** iOS StoreKit 分发环境;TestFlight 保留 OTA、禁用整包外跳。 */isTestFlight?: boolean;}): void {if (resolved.authApiBaseUrl !== undefined) {diff --git a/apps/mobile/src/i18n/locales/en/settings.json b/apps/mobile/src/i18n/locales/en/settings.jsonindex a0a4bd89ad..232abf115f 100644--- a/apps/mobile/src/i18n/locales/en/settings.json+++ b/apps/mobile/src/i18n/locales/en/settings.json@@ -19,9 +19,14 @@"desktopVersion": "Desktop {{version}}","devNoOta": "Development build; OTA updates unavailable","checkAction": "Check for Updates",+ "testFlightCheckAction": "Check for Content Updates","checking": "Checking","updating": "Updating","checkingAccessibility": "Checking for updates",+ "testFlightCheckingAccessibility": "Checking for content updates",+ "testFlightUpdateManaged": "TestFlight manages test build updates",+ "testFlightNoContentUpdate": "No content updates are available. Check TestFlight for new test builds.",+ "testFlightContentUpdateUnavailable": "This build cannot check for content updates. Check TestFlight for new test builds.","bundleUpdateFound": "App package update available","upToDate": "Already up to date","bundleUpToDateNoOta": "App package is up to date; this version does not support OTA updates",diff --git a/apps/mobile/src/i18n/locales/ja/settings.json b/apps/mobile/src/i18n/locales/ja/settings.jsonindex 6c5cedc996..356fb101f5 100644--- a/apps/mobile/src/i18n/locales/ja/settings.json+++ b/apps/mobile/src/i18n/locales/ja/settings.json@@ -19,9 +19,14 @@"desktopVersion": "デスクトップ版 {{version}}","devNoOta": "開発ビルドのため OTA 更新は利用できません","checkAction": "更新を確認",+ "testFlightCheckAction": "コンテンツ更新を確認","checking": "確認中","updating": "更新中","checkingAccessibility": "更新を確認しています",+ "testFlightCheckingAccessibility": "コンテンツ更新を確認しています",+ "testFlightUpdateManaged": "テスト版アプリの更新は TestFlight で管理されます",+ "testFlightNoContentUpdate": "利用可能なコンテンツ更新はありません。新しいテスト版は TestFlight で確認してください。",+ "testFlightContentUpdateUnavailable": "このビルドではコンテンツ更新を確認できません。新しいテスト版は TestFlight で確認してください。","bundleUpdateFound": "アプリ本体の更新があります","upToDate": "すでに最新の状態です","bundleUpToDateNoOta": "アプリ本体は最新です。このバージョンは OTA 更新に対応していません",diff --git a/apps/mobile/src/i18n/locales/ko/settings.json b/apps/mobile/src/i18n/locales/ko/settings.jsonindex 67201444a7..16b5e331a2 100644--- a/apps/mobile/src/i18n/locales/ko/settings.json+++ b/apps/mobile/src/i18n/locales/ko/settings.json@@ -19,9 +19,14 @@"desktopVersion": "데스크톱 버전 {{version}}","devNoOta": "개발 빌드에서는 OTA 업데이트를 사용할 수 없습니다","checkAction": "업데이트 확인",+ "testFlightCheckAction": "콘텐츠 업데이트 확인","checking": "확인 중","updating": "업데이트 중","checkingAccessibility": "업데이트를 확인하는 중",+ "testFlightCheckingAccessibility": "콘텐츠 업데이트를 확인하는 중",+ "testFlightUpdateManaged": "테스트 빌드 업데이트는 TestFlight에서 관리합니다",+ "testFlightNoContentUpdate": "사용 가능한 콘텐츠 업데이트가 없습니다. 새 테스트 빌드는 TestFlight에서 확인해 주세요.",+ "testFlightContentUpdateUnavailable": "이 빌드에서는 콘텐츠 업데이트를 확인할 수 없습니다. 새 테스트 빌드는 TestFlight에서 확인해 주세요.","bundleUpdateFound": "앱 패키지 업데이트가 있습니다","upToDate": "이미 최신 버전입니다","bundleUpToDateNoOta": "앱 패키지는 최신입니다. 현재 버전은 OTA 업데이트를 지원하지 않습니다",diff --git a/apps/mobile/src/i18n/locales/zh-CN/settings.json b/apps/mobile/src/i18n/locales/zh-CN/settings.jsonindex d2a28dd85e..7e61d4c2bc 100644--- a/apps/mobile/src/i18n/locales/zh-CN/settings.json+++ b/apps/mobile/src/i18n/locales/zh-CN/settings.json@@ -19,9 +19,14 @@"desktopVersion": "桌面版 {{version}}","devNoOta": "开发版,热更不可用","checkAction": "检查更新",+ "testFlightCheckAction": "检查内容更新","checking": "检查中","updating": "更新中","checkingAccessibility": "正在检查更新",+ "testFlightCheckingAccessibility": "正在检查内容更新",+ "testFlightUpdateManaged": "测试版安装更新由 TestFlight 管理",+ "testFlightNoContentUpdate": "当前没有可用的内容更新。新测试版本请在 TestFlight 中查看。",+ "testFlightContentUpdateUnavailable": "当前构建无法检查内容更新。新测试版本请在 TestFlight 中查看。","bundleUpdateFound": "发现整包更新","upToDate": "已是最新版本","bundleUpToDateNoOta": "整包已是最新,当前版本不支持热更新",diff --git a/apps/mobile/src/update/bundleUpdate.test.ts b/apps/mobile/src/update/bundleUpdate.test.tsindex afa502ad3c..10c2f22aad 100644--- a/apps/mobile/src/update/bundleUpdate.test.ts+++ b/apps/mobile/src/update/bundleUpdate.test.ts@@ -4,6 +4,7 @@ import {evaluateBundleUpdate,parseLatestRelease,preferredInstallUrl,+ shouldCheckBundleUpdate,} from './bundleUpdate';const VALID = {@@ -14,6 +15,24 @@ const VALID = {itmsUrl: 'itms-services://?action=download-manifest&url=https%3A%2F%2Fx%2Fplist%2F42',};+describe('shouldCheckBundleUpdate', () => {+ it.each([+ ['非自建分发', false, false, false, false],+ ['正式自建分发', true, false, false, true],+ ['审核模式', true, true, false, false],+ ['TestFlight', true, false, true, false],+ ] as const)(+ '%s → %s',+ (_label, isSelfHosted, isReviewMode, isTestFlightBuild, expected) => {+ expect(shouldCheckBundleUpdate({+ isSelfHosted,+ isReviewMode,+ isTestFlightBuild,+ })).toBe(expected);+ },+ );+});+describe('parseLatestRelease', () => {it('接受完整记录', () => {expect(parseLatestRelease(VALID)?.runtimeVersion).toBe('rtv-new');diff --git a/apps/mobile/src/update/bundleUpdate.ts b/apps/mobile/src/update/bundleUpdate.tsindex 8388540bc4..faf50dcb49 100644--- a/apps/mobile/src/update/bundleUpdate.ts+++ b/apps/mobile/src/update/bundleUpdate.ts@@ -45,6 +45,23 @@ export interface EvaluateBundleUpdateInput {const NO_UPDATE: BundleUpdateEvaluation = { needsUpdate: false, forced: false, target: null };+/**+ * 整包更新只属于自建分发渠道。+ * Review 构建与 TestFlight 构建都不能展示外部安装入口;+ * TestFlight 的 JS OTA 由独立通道继续处理。+ */+export function shouldCheckBundleUpdate({+ isSelfHosted,+ isReviewMode,+ isTestFlightBuild,+}: {+ isSelfHosted: boolean;+ isReviewMode: boolean;+ isTestFlightBuild: boolean;+}): boolean {+ return isSelfHosted && !isReviewMode && !isTestFlightBuild;+}+/** 校验并收窄 `/latest` 响应为 LatestReleaseRecord;字段缺失即返回 null(宁可不提示,不误导)。 */export function parseLatestRelease(value: unknown): LatestReleaseRecord | null {if (!value || typeof value !== 'object') return null;diff --git a/apps/mobile/src/update/manualUpdateCheck.test.ts b/apps/mobile/src/update/manualUpdateCheck.test.tsindex 5181ca3475..2313f09118 100644--- a/apps/mobile/src/update/manualUpdateCheck.test.ts+++ b/apps/mobile/src/update/manualUpdateCheck.test.ts@@ -71,7 +71,7 @@ describe('runManualUpdateCheck', () => {expect(input.checkOtaUpdate).not.toHaveBeenCalled();});- it('keeps non-self-host builds on their existing OTA-only path', async () => {+ it('keeps OTA checks available when the caller disables full-package checks', async () => {const input = deps();await expect(runManualUpdateCheck(input)).resolves.toEqual({ kind: 'up-to-date' });expect(input.checkOtaUpdate).toHaveBeenCalledOnce();diff --git a/apps/mobile/src/update/resumeUpdateCheck.test.ts b/apps/mobile/src/update/resumeUpdateCheck.test.tsindex ba405a4005..58da41304b 100644--- a/apps/mobile/src/update/resumeUpdateCheck.test.ts+++ b/apps/mobile/src/update/resumeUpdateCheck.test.ts@@ -157,8 +157,10 @@ describe('createResumeUpdateChecker 整包路径', () => {it('bundleCheckEnabled=false → skipped,不拉 /latest', async () => {const deps = makeDeps({ bundleCheckEnabled: false });- const { bundle } = await runOnce(deps);+ const { ota, bundle } = await runOnce(deps);+ expect(ota).toBe('up-to-date');expect(bundle).toBe('skipped');+ expect(deps.checkForUpdateAsync).toHaveBeenCalledOnce();expect(deps.fetchLatest).not.toHaveBeenCalled();});diff --git a/apps/mobile/src/update/useBundleUpdatePrompt.ts b/apps/mobile/src/update/useBundleUpdatePrompt.tsindex ff8a321b2e..95b67db3e5 100644--- a/apps/mobile/src/update/useBundleUpdatePrompt.ts+++ b/apps/mobile/src/update/useBundleUpdatePrompt.ts@@ -10,9 +10,17 @@ import { Alert, Linking, Platform } from 'react-native';import Constants from 'expo-constants';import * as Updates from 'expo-updates';import { i18n } from '@/i18n';-import { IS_OTA_SELFHOST, REVIEW_MODE } from '@/config/env';+import {+ IS_OTA_SELFHOST,+ IS_TESTFLIGHT_BUILD,+ REVIEW_MODE,+} from '@/config/env';import { fetchLatestRelease } from './fetchLatestRelease';-import { evaluateBundleUpdate, preferredInstallUrl } from './bundleUpdate';+import {+ evaluateBundleUpdate,+ preferredInstallUrl,+ shouldCheckBundleUpdate,+} from './bundleUpdate';import type { BundleUpdateCheckOutcome } from './manualUpdateCheck';import { markForcedPrompted } from './resumeUpdateCheck';import { isCanaryChannel } from './canaryChannelStore';@@ -76,6 +84,11 @@ export function useBundleUpdatePrompt({isCanary = isCanaryChannel(),}: Options = {}) {const [state, setState] = useState<CheckState>('idle');+ const bundleCheckEnabled = shouldCheckBundleUpdate({+ isSelfHosted: IS_OTA_SELFHOST,+ isReviewMode: REVIEW_MODE,+ isTestFlightBuild: IS_TESTFLIGHT_BUILD,+ });const inFlightChannels = useRef(new Set<boolean>());const channelEpochRef = useRef(0);const previousChannelRef = useRef(isCanary);@@ -87,8 +100,8 @@ export function useBundleUpdatePrompt({}const checkNow = useCallback(async (): Promise<BundleUpdateCheckOutcome> => {- // 审核模式:入口按钮已隐藏,这里再挡一层(状态由代码保证,不依赖 UI 层记得隐藏)。- if (!IS_OTA_SELFHOST || REVIEW_MODE) return 'skipped';+ // 审核模式与 TestFlight 都禁止整包外跳;这里再挡一层,不依赖调用方记得隐藏入口。+ if (!bundleCheckEnabled) return 'skipped';if (inFlightChannels.current.has(isCanary)) return 'busy';inFlightChannels.current.add(isCanary);const requestEpoch = channelEpochRef.current;@@ -127,14 +140,14 @@ export function useBundleUpdatePrompt({} finally {inFlightChannels.current.delete(isCanary);}- }, [isCanary, notifyWhenUpToDate]);+ }, [bundleCheckEnabled, isCanary, notifyWhenUpToDate]);useEffect(() => {- if (auto && IS_OTA_SELFHOST) void checkNow();+ if (auto && bundleCheckEnabled) void checkNow();// auto hook 在登录/切账号导致 channel 变化时再检查一次,避免新的账号// 继续沿用旧账号的 release 指针;手动检查入口仍由调用方通过 checkNow 触发。// eslint-disable-next-line react-hooks/exhaustive-deps- }, [auto, isCanary]);+ }, [auto, bundleCheckEnabled, isCanary]);return { state, checkNow };}diff --git a/apps/mobile/src/update/useResumeUpdateCheck.ts b/apps/mobile/src/update/useResumeUpdateCheck.tsindex 2c0b8105ca..c33223767c 100644--- a/apps/mobile/src/update/useResumeUpdateCheck.ts+++ b/apps/mobile/src/update/useResumeUpdateCheck.ts@@ -3,20 +3,30 @@//// 挂载点 app/_layout.tsx。非自建变体(IS_OTA_SELFHOST=false)完全 no-op:不订阅、不发起// 任何网络。JS OTA 部分与启动热更门同 gate(自建 + 非 dev + expo-updates 可用);整包-// 检查部分与 useBundleUpdatePrompt 同 gate(自建即可,dev 下 runtimeVersion 拿不到会被-// evaluateBundleUpdate 判为无更新,天然安全)。+// 检查部分与 useBundleUpdatePrompt 同 gate(自建 + 非审核 + 非 TestFlight)。import { useEffect } from 'react';import { AppState, Platform } from 'react-native';import Constants from 'expo-constants';import * as Updates from 'expo-updates';-import { IS_OTA_SELFHOST, REVIEW_MODE } from '@/config/env';+import {+ IS_OTA_SELFHOST,+ IS_TESTFLIGHT_BUILD,+ REVIEW_MODE,+} from '@/config/env';+import { shouldCheckBundleUpdate } from './bundleUpdate';import { fetchLatestRelease } from './fetchLatestRelease';import { createResumeUpdateChecker } from './resumeUpdateCheck';import { promptBundleUpdate } from './useBundleUpdatePrompt';import { isCanaryChannel } from './canaryChannelStore';export function useResumeUpdateCheck(isCanary = isCanaryChannel()): void {+ const bundleCheckEnabled = shouldCheckBundleUpdate({+ isSelfHosted: IS_OTA_SELFHOST,+ isReviewMode: REVIEW_MODE,+ isTestFlightBuild: IS_TESTFLIGHT_BUILD,+ });+useEffect(() => {if (!IS_OTA_SELFHOST) return; // 非自建变体无静默更新通道,连 AppState 都不订阅if (REVIEW_MODE) return; // 审核模式:关闭本 hook 的 resume 静默检查,不订阅 AppState@@ -26,7 +36,7 @@ export function useResumeUpdateCheck(isCanary = isCanaryChannel()): void {otaEnabled: IS_OTA_SELFHOST && !__DEV__ && Updates.isEnabled,checkForUpdateAsync: () => Updates.checkForUpdateAsync(),fetchUpdateAsync: () => Updates.fetchUpdateAsync(),- bundleCheckEnabled: IS_OTA_SELFHOST,+ bundleCheckEnabled,fetchLatest: () => fetchLatestRelease(Platform.OS === 'android' ? 'android' : 'ios',undefined,@@ -47,5 +57,5 @@ export function useResumeUpdateCheck(isCanary = isCanaryChannel()): void {current = false;subscription.remove();};- }, [isCanary]);+ }, [bundleCheckEnabled, isCanary]);}diff --git a/i18n/GLOSSARY.md b/i18n/GLOSSARY.mdindex 2d6ec0f1c2..ef4f932cbe 100644--- a/i18n/GLOSSARY.md+++ b/i18n/GLOSSARY.md@@ -124,6 +124,10 @@**注意别指望 `--update-baseline` 帮你收尾。** `proposed` 存在的理由正是「已知有存量不一致」,改成 `decided` 的那一刻这些告警会变成阻断违规;而 `--update-baseline` 只删不加,遇到 baseline 里没有的指纹会直接拒绝。所以裁决时只有两条路:要么把命中逐条读语境改掉,要么先人工把已 review 过的指纹写进 `i18n/glossary-baseline.json` 冻结存量,之后再用 `--update-baseline` 做修剪。+### Content Update++指不更换 TestFlight 或商店安装包、可通过 OTA 下发的 JS 与资源更新。当前先采用四语直译并登记为待讨论术语,避免与整包更新或测试版本更新混称。+### Device CodeOAuth 2.0 Device Authorization Grant 中由用户在另一设备验证页输入的一次性代码。当前先采用各语言直译,作为待产品裁决术语登记,避免后续界面出现“设备代码/配对码/认证码”等多套说法。diff --git a/i18n/glossary.json b/i18n/glossary.jsonindex 02b4d53107..706d772b28 100644--- a/i18n/glossary.json+++ b/i18n/glossary.json@@ -12,6 +12,17 @@"desktop:settings.help.qnaFeedbackBodyTemplate"],"terms": [+ {+ "id": "content-update",+ "status": "proposed",+ "en": "Content Update",+ "translations": {+ "zh-CN": "内容更新",+ "ja": "コンテンツ更新",+ "ko": "콘텐츠 업데이트"+ },+ "note": "指不更换 TestFlight 或商店安装包、可通过 OTA 下发的 JS 与资源更新。当前先采用四语直译并登记为待讨论术语,避免与整包更新或测试版本更新混称。"+ },{"id": "device-code","status": "proposed",