Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): iOS 状态栏样式改走 VC-based 通道,适配 iOS 27 (#1129)
Chris Zhang5818b8d0dd6c
diff --git a/apps/mobile/app.json b/apps/mobile/app.jsonindex 283c9192cc..8da337e303 100644--- a/apps/mobile/app.json+++ b/apps/mobile/app.json@@ -19,6 +19,7 @@},"infoPlist": {"ITSAppUsesNonExemptEncryption": false,+ "UIViewControllerBasedStatusBarAppearance": true,"UISupportedInterfaceOrientations": ["UIInterfaceOrientationPortrait","UIInterfaceOrientationPortraitUpsideDown",diff --git a/apps/mobile/app/(auth)/login.tsx b/apps/mobile/app/(auth)/login.tsxindex 321d7835fd..c82b59e2cc 100644--- a/apps/mobile/app/(auth)/login.tsx+++ b/apps/mobile/app/(auth)/login.tsx@@ -1,3 +1,4 @@+import { Stack } from 'expo-router';import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { Animated, Easing, Keyboard, Linking, Platform, Pressable, StyleSheet, View } from 'react-native';@@ -5,6 +6,8 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';import type { AccountDeletionStatus, SocialProvider, VerificationKind } from '@cindy/auth-client';import { useAuth } from '@/auth/AuthContext';+import { useLoginFirstLaunchLight } from '@/auth/loginFirstLaunchGate';+import { resolveStartupSplashHandoff } from '@/auth/startupSplashContinuity';import {CN_PHONE_PREFIX,isCompleteCnPhone,@@ -87,6 +90,13 @@ export default function LoginScreen() {const auth = useAuth();const stage = useLoginSurface();const insets = useSafeAreaInsets();+ // 舞台有效主题(首启亮色门可强制 light,与系统主题可能不一致):状态栏样式+ // 必须跟舞台而不是系统,经 screen option 走 VC-based 通道(见 _layout 注释)。+ const { mode: systemTheme } = useTheme();+ const firstLaunchGate = useLoginFirstLaunchLight();+ const stageTheme =+ resolveStartupSplashHandoff(firstLaunchGate, systemTheme).targetTheme ??+ systemTheme;const handoff = useLoginHandoffOptional();const handoffDispatch = handoff?.dispatch;// readiness 锚之一(v6.3):登录面板已挂载(防面板未挂载先播 panel 步)@@ -1163,6 +1173,15 @@ export default function LoginScreen() {keyboardShiftPx={keyboardShift}testID="login.screen">+ {/* 渲染为 null,仅把状态栏样式写进本屏 screen options。iOS 专用:+ Android 由舞台内组件式 StatusBar 控制,不走 RNS 双轨 */}+ {Platform.OS === 'ios' ? (+ <Stack.Screen+ options={{+ statusBarStyle: stageTheme === 'dark' ? 'light' : 'dark',+ }}+ />+ ) : null}{/* 外层未变换测量 wrapper(v5 冻结拓扑):持布局基线,不参与任何 translate */}<Viewcollapsable={false}diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsxindex 8191619493..c02c148072 100644--- a/apps/mobile/app/_layout.tsx+++ b/apps/mobile/app/_layout.tsx@@ -8,7 +8,7 @@ import {} from 'expo-router';import { StatusBar } from 'expo-status-bar';import { useEffect, useMemo, type ReactElement } from 'react';-import { Alert, Pressable, StyleSheet, View } from 'react-native';+import { Alert, Platform, Pressable, StyleSheet, View } from 'react-native';import { Text } from '@/components/AppText';import {fontWeight,@@ -20,7 +20,9 @@ import {} from '@/theme';import { SafeAreaProvider } from 'react-native-safe-area-context';import { AuthProvider, useAuth } from '@/auth/AuthContext';+import { useLoginFirstLaunchLight } from '@/auth/loginFirstLaunchGate';import { loginText } from '@/auth/loginMessages';+import { resolveStartupSplashHandoff } from '@/auth/startupSplashContinuity';import {MobileLoginHandoffProvider,useLoginHandoff,@@ -54,6 +56,17 @@ function NavigationGate() {const segments = useSegments();const { mode, colors } = useTheme();const { releaseSplash, splashActive } = useStartupSplash();+ // iOS 状态栏样式走 react-native-screens 的 VC-based 通道(Info.plist 已翻+ // UIViewControllerBasedStatusBarAppearance=YES):iOS 27 起 UIKit 不再接受+ // RN StatusBar 依赖的废弃全局 API(setStatusBarStyle),expo-status-bar 组件+ // 在 iOS 上已失效且会触发 RCTLogError,iOS 侧不得再挂载。Android 老链路正常,+ // 继续用组件式 StatusBar(含 Stack 未挂载的启动闸门期),不走 RNS 双轨。+ // splash 覆盖层是登录品牌舞台(首启亮色门可能强制 light):覆盖期间随舞台+ // 有效主题,释放后随系统主题;首启门 pending 时舞台不渲染品牌,跟系统即可。+ const firstLaunchGate = useLoginFirstLaunchLight();+ const stageTheme =+ resolveStartupSplashHandoff(firstLaunchGate, mode).targetTheme ?? mode;+ const statusBarTheme = splashActive ? stageTheme : mode;const navigationTheme = useMemo(() =>createNavigationTheme(@@ -96,12 +109,19 @@ function NavigationGate() {return (<NavigationThemeProvider value={navigationTheme}>- {/* splash 覆盖层仍在时状态栏保持浅色;淡出开始后切回主题样式 */}- <StatusBar style={splashActive || mode === 'dark' ? 'light' : 'dark'} />+ {/* Android 专用:splash 覆盖层仍在时状态栏保持浅色;淡出开始后切回主题样式 */}+ {Platform.OS === 'android' ? (+ <StatusBar+ style={splashActive || mode === 'dark' ? 'light' : 'dark'}+ />+ ) : null}<StackscreenOptions={{headerShown: false,contentStyle: { backgroundColor: colors.surface },+ ...(Platform.OS === 'ios'+ ? { statusBarStyle: statusBarTheme === 'dark' ? 'light' : 'dark' }+ : null),// iOS 26 起 react-native-screens 的返回手势默认全屏识别(fullScreenSwipe 默认 true),// 判定范围过大:会与消息内表格/代码块的横向 ScrollView 抢手势,拖动内容时还会误触返回。// 限定手势起始点在屏幕前缘 44pt 内(end = 距前缘最大 x),恢复经典边缘返回的判定范围;diff --git a/apps/mobile/src/__tests__/nativeAppConfig.test.ts b/apps/mobile/src/__tests__/nativeAppConfig.test.tsindex 0293edb08b..fadcfd2e64 100644--- a/apps/mobile/src/__tests__/nativeAppConfig.test.ts+++ b/apps/mobile/src/__tests__/nativeAppConfig.test.ts@@ -423,6 +423,23 @@ describe('mobile native app config', () => {expect(eas.build['production-global'].extends).toBe('store-global-base');});+ it('keeps iOS status bar appearance view-controller based (iOS 27 requirement)', () => {+ const appJson = JSON.parse(+ readFileSync(resolve(process.cwd(), 'app.json'), 'utf8'),+ );+ const buildConfig = require(resolve(process.cwd(), 'app.config.js'));++ // iOS 27 起 RN StatusBar 的废弃全局链路失效,状态栏样式依赖 VC-based 通道+ // (react-native-screens screen options)。该键被误删/翻回 false 时,浅色模式+ // 状态栏会停在白字且无法 JS 热修(冷更锁定),必须由本断言挡住。+ expect(+ appJson.expo.ios.infoPlist.UIViewControllerBasedStatusBarAppearance,+ ).toBe(true);+ // app.config.js 不得剥离该键:以 resolved config 为准再断言一次。+ const cn = buildConfig({ config: appJson.expo });+ expect(cn.ios.infoPlist.UIViewControllerBasedStatusBarAppearance).toBe(true);+ });+it('keeps audio capture foreground-only in native builds', () => {const appJson = JSON.parse(readFileSync(resolve(process.cwd(), 'app.json'), 'utf8'),diff --git a/apps/mobile/src/__tests__/statusBarVcMigration.test.ts b/apps/mobile/src/__tests__/statusBarVcMigration.test.tsnew file mode 100644index 0000000000..3d83a2975f--- /dev/null+++ b/apps/mobile/src/__tests__/statusBarVcMigration.test.ts@@ -0,0 +1,79 @@+import { readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import { describe, expect, it } from 'vitest';++/**+ * iOS 状态栏 VC-based 迁移的源码合同测试(PR #1129)。+ *+ * 背景:Info.plist 的 UIViewControllerBasedStatusBarAppearance=YES 后+ * (见 nativeAppConfig.test.ts 的对应断言),RN StatusBar 的样式/隐藏调用在+ * iOS 上失效并触发 RCTLogError;iOS 改经 react-native-screens 的+ * statusBarStyle / statusBarHidden screen options,Android 保持组件式+ * StatusBar 老链路。这些平台守卫分支散在 4 个文件里,merge conflict 误删+ * 任何一个守卫都不会有类型错误——用源码合同把它们钉住。+ */+const read = (relativePath: string) =>+ readFileSync(resolve(process.cwd(), relativePath), 'utf8');++describe('status bar VC-based migration source contracts', () => {+ it('_layout.tsx: Android 用组件式 StatusBar,iOS 用 Stack screenOptions statusBarStyle', () => {+ const source = read('app/_layout.tsx');+ // Android-only 组件式 StatusBar(覆盖 Stack 未挂载的启动闸门期)+ expect(source).toContain("{Platform.OS === 'android' ? (");+ expect(source).toContain(+ "style={splashActive || mode === 'dark' ? 'light' : 'dark'}",+ );+ // iOS-only 的 RNS 通道:statusBarStyle 只在 iOS 进 screenOptions+ expect(source).toContain("...(Platform.OS === 'ios'");+ expect(source).toContain(+ "{ statusBarStyle: statusBarTheme === 'dark' ? 'light' : 'dark' }",+ );+ // splash 覆盖期跟舞台有效主题(首启亮色门),释放后跟系统主题+ expect(source).toContain(+ 'const statusBarTheme = splashActive ? stageTheme : mode;',+ );+ });++ it('MobileLoginHandoffStage.tsx: 组件式 StatusBar 必须锁在 Android 分支内', () => {+ const source = read('src/components/MobileLoginHandoffStage.tsx');+ expect(source).toContain("{Platform.OS === 'android' ? (");+ expect(source).toContain(+ "<StatusBar style={mode === 'dark' ? 'light' : 'dark'} />",+ );+ // iOS 不得无守卫挂载 expo-status-bar 组件(会触发 RCTLogError):+ // 每个 <StatusBar 出现点都要能配对到 android 守卫。+ const statusBarUses = source.match(/<StatusBar /g) ?? [];+ const androidGuards =+ source.match(/Platform\.OS === 'android' \? \(\s*<StatusBar /g) ?? [];+ expect(statusBarUses.length).toBeGreaterThan(0);+ expect(androidGuards.length).toBe(statusBarUses.length);+ });++ it('ImageLightbox.tsx: iOS 走宿主屏 statusBarHidden option,Android 保留 Modal 内 StatusBar hidden', () => {+ const source = read('src/session/ImageLightbox.tsx');+ // iOS:经 navigation.setOptions 走 VC-based 通道,卸载时恢复+ expect(source).toContain("if (Platform.OS !== 'ios') return;");+ expect(source).toContain(+ 'navigation.setOptions({ statusBarHidden: true });',+ );+ expect(source).toContain(+ 'navigation.setOptions({ statusBarHidden: false });',+ );+ // Android:组件式 hidden 保持老链路,且必须锁在 android 守卫内+ expect(source).toContain(+ "{Platform.OS === 'android' ? <StatusBar hidden /> : null}",+ );+ });++ it('login.tsx: 登录屏按舞台有效主题在 iOS 设置 statusBarStyle screen option', () => {+ const source = read('app/(auth)/login.tsx');+ // 首启亮色门可强制舞台为 light(系统可能是 dark):样式必须跟舞台而非系统+ expect(source).toContain(+ 'resolveStartupSplashHandoff(firstLaunchGate, systemTheme).targetTheme',+ );+ expect(source).toContain("{Platform.OS === 'ios' ? (");+ expect(source).toContain(+ "statusBarStyle: stageTheme === 'dark' ? 'light' : 'dark',",+ );+ });+});diff --git a/apps/mobile/src/components/MobileLoginHandoffStage.tsx b/apps/mobile/src/components/MobileLoginHandoffStage.tsxindex 3ef3dd8a5e..66b656faa3 100644--- a/apps/mobile/src/components/MobileLoginHandoffStage.tsx+++ b/apps/mobile/src/components/MobileLoginHandoffStage.tsx@@ -3,6 +3,7 @@ import {Animated,Easing,Image,+ Platform,StyleSheet,useWindowDimensions,View,@@ -271,8 +272,13 @@ function MobileLoginHandoffStageInner({style={[styles.root, { backgroundColor: colors.login.bgBase }]}testID={testID}>- {/* 白底体系:状态栏随主题模式(旧红底 splash 的恒 light 样式随之退役) */}- <StatusBar style={mode === 'dark' ? 'light' : 'dark'} />+ {/* 白底体系:状态栏随主题模式。Android 继续走组件式 StatusBar(覆盖 Stack+ 未挂载的闸门屏);iOS 27 起 RN StatusBar 全局 API 失效,iOS 侧由 _layout /+ login 的 statusBarStyle screen option 按舞台有效主题控制,导航器外+ (端点闸门错误屏)由系统外观自动适配。 */}+ {Platform.OS === 'android' ? (+ <StatusBar style={mode === 'dark' ? 'light' : 'dark'} />+ ) : null}{showBrand ? (// 键盘位移层(demo kb-shift 同构):品牌随面板整体上顶,根 View 纯平底不动<Viewdiff --git a/apps/mobile/src/session/ImageLightbox.tsx b/apps/mobile/src/session/ImageLightbox.tsxindex 692798328f..1b247a60fa 100644--- a/apps/mobile/src/session/ImageLightbox.tsx+++ b/apps/mobile/src/session/ImageLightbox.tsx@@ -11,12 +11,14 @@* 仅图片走本组件;video / audio / 文件仍走 MessagePayloadModal。* lightbox 是常黑沉浸语境,黑白系颜色为刻意豁免(对齐桌面 docs/design-rules/cindy-design-system.md overlay/lightbox 语义豁免),不走主题 token。*/+import { useNavigation } from 'expo-router';import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import {ActivityIndicator,FlatList,Modal,+ Platform,Pressable,StatusBar,StyleSheet,@@ -433,6 +435,19 @@ export const ImageLightbox = memo(function ImageLightbox({onClose();}, [annotationSubmitting, isAnnotating, exitAnnotationMode, onClose]);+ // iOS 沉浸式隐藏状态栏:经宿主屏的 screen option 走 VC-based 通道(iOS 27 起+ // RN StatusBar 全局 API 失效;transparent Modal 不接管状态栏,穿透到宿主屏)。+ // Android 继续用 Modal 内组件式 <StatusBar hidden>,不走 RNS 双轨。+ // 只触碰 statusBarHidden 一个键,泛型收窄到最小面。+ const navigation = useNavigation<{+ setOptions: (options: { statusBarHidden: boolean }) => void;+ }>();+ useEffect(() => {+ if (Platform.OS !== 'ios') return;+ navigation.setOptions({ statusBarHidden: true });+ return () => navigation.setOptions({ statusBarHidden: false });+ }, [navigation]);+return (<ModalanimationType="fade"@@ -442,7 +457,7 @@ export const ImageLightbox = memo(function ImageLightbox({transparentvisible>- <StatusBar hidden />+ {Platform.OS === 'android' ? <StatusBar hidden /> : null}<GestureHandlerRootView style={styles.root} testID="message.imageLightbox"><Animated.View pointerEvents="none" style={[styles.backdrop, backdropStyle]} /><FlatList