Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 修复 Duo 伙伴顶栏重复占用状态区

Dash0211c2530f23
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index 16d5a6eb34..e278716589 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -786,7 +786,7 @@ const SESSION_ACTION_TEST_IDS = {
} satisfies Record<SessionActionStripActionId, string>;
const COMPOSER_CONTROL_HIT_SLOP = { bottom: 8, left: 8, right: 8, top: 8 };
/**
- * The companion chat draws its own header row (back, identity, settings). Hide the native bar the
+ * When the companion uses an in-content header row, hide the native bar the
* task header may have configured while the entry was still resolving, so its title and sync
* spinner never sit on top of the companion identity. Stable object: expo-router applies screen
* options in a layout effect.
@@ -3017,7 +3017,7 @@ function SessionScreenContent({ beforeSessionSwitchRef, newSessionActionRef }: S
const adaptiveWindow = useAdaptiveWindow();
const paneLayout = useSessionPaneLayout();
const horizontalSystemHeader = Platform.OS === 'ios' && adaptiveWindow.barEdge === 'none'
- && !paneLayout.persistent && !shareSelectionActive && !companionChat;
+ && !paneLayout.persistent && !shareSelectionActive;
const composerRegion = keyboardControlRegion(adaptiveWindow, keyboardState.height);
const detailViewport = useMemo(() => ({ x: paneLayout.detail.x, y: paneLayout.detail.y, width: paneLayout.detail.width, height: windowDimensions.height }),
[paneLayout.detail.x, paneLayout.detail.y, paneLayout.detail.width, windowDimensions.height]);
@@ -9837,8 +9837,9 @@ function SessionScreenContent({ beforeSessionSwitchRef, newSessionActionRef }: S
<>
<Stack.Screen options={{ gestureEnabled: !sessionListDrawerOverlayMounted }} />
{companionHeaderShown ? <>
- <Stack.Screen options={COMPANION_NATIVE_HEADER_OPTIONS} />
+ {horizontalSystemHeader ? null : <Stack.Screen options={COMPANION_NATIVE_HEADER_OPTIONS} />}
<CompanionHeader key={`${auth.accountGeneration}:${deviceId}:${companionResource.ref.id}`}
+ nativeHeader={horizontalSystemHeader}
resource={companionResource} deviceId={deviceId} deviceName={deviceName} online={!remoteUnavailableReason} controlsReady={companionEntry.ready}
settingsRequest={companionSettingsRequest?.sessionId === sessionId ? companionSettingsRequest : undefined}
working={!!companionWorkingLabel}
diff --git a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx
index 1db1add04d..5725ad2cc1 100644
--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx
+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx
@@ -61,10 +61,14 @@ vi.mock('react-native', () => {
});
vi.mock('expo-router', () => ({
useIsFocused: () => h.focused,
- Stack: { Screen: () => null },
+ Stack: {
+ Screen: ({ options }: any) => typeof options.headerTitle === 'function' ? options.headerTitle() : null,
+ Toolbar: Object.assign(({ children }: any) => children, { View: ({ children }: any) => children }),
+ },
useRouter: () => ({ back: vi.fn(), replace: vi.fn() }),
useFocusEffect: (effect: () => void) => useEffect(effect, [effect]),
}));
+vi.mock('expo-router/react-navigation', () => ({ useHeaderHeight: () => 72 }));
vi.mock('react-native-safe-area-context', () => ({ SafeAreaView: ({ children }: any) => el('main', null, children), useSafeAreaInsets: () => ({ top: 59, bottom: 34, left: 0, right: 0 }) }));
vi.mock('@/session/SessionHeaderNativeControls', () => ({ SessionHeaderNativeBlur: ({ height, fadeInside }: any) => { h.headerBlur.push(height); h.headerFade.push(fadeInside); return null; } }));
vi.mock('react-i18next', async (importOriginal) => ({
@@ -389,8 +393,8 @@ describe('group timeline', () => {
it('floats the iOS header on the task header blur instead of an opaque band', async () => {
await render();
- // Before the header is measured the blur still covers the status bar plus one bar row.
- expect(h.headerBlur.at(-1)).toBe(59 + 44);
+ // Duo's native measurement already includes its shared status row; do not add another 44pt.
+ expect(h.headerBlur.at(-1)).toBe(72);
// The two-line identity stays over solid blur; the feather starts at the header's lower edge.
expect(h.headerFade.at(-1)).toBe(0);
});
diff --git a/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx b/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx
index 98ec99847a..a6e0cf99dd 100644
--- a/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx
+++ b/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx
@@ -15,12 +15,14 @@ const h = vi.hoisted(() => ({
homeSheet: {} as any,
}));
vi.mock('react-native', () => ({
+ useWindowDimensions: () => ({ width: 662, height: 942 }),
Keyboard: { dismiss: h.dismiss },
View: ({ children, testID }: any) => createElement('div', { 'data-testid': testID }, children),
Pressable: ({ children, onPress, testID, disabled }: any) => createElement('button', { onClick: onPress, disabled, 'data-testid': testID },
typeof children === 'function' ? children({ pressed: false }) : children),
StyleSheet: { create: (s: unknown) => s },
}));
+vi.mock('react-native-safe-area-context', () => ({ useSafeAreaInsets: () => ({ top: 72, bottom: 0, left: 0, right: 0 }) }));
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (s: string) => s, i18n: { language: 'en' } }) }));
vi.mock('@/auth/AuthContext', () => ({ useAuth: () => h.auth }));
vi.mock('@/components/AppText', () => ({ Text: ({ children }: any) => createElement('span', null, children) }));
@@ -39,7 +41,13 @@ vi.mock('@/session/useCompanionGlanceTodos', () => ({
dueTodos: () => [],
useGlanceDueSeen: () => ({ unseen: h.unseen, markSeen: h.markSeen }),
}));
-vi.mock('expo-router', () => ({ useRouter: () => ({ push: h.push }) }));
+vi.mock('expo-router', () => ({ useRouter: () => ({ push: h.push }), Stack: {
+ Screen: ({ options }: any) => { h.screenOptions.push(options); return typeof options.headerTitle === 'function'
+ ? createElement('div', { 'data-testid': 'native-title' }, options.headerTitle()) : null; },
+ Toolbar: Object.assign(({ children, placement }: any) => createElement('div', { 'data-toolbar': placement }, children), {
+ View: ({ children }: any) => children,
+ }),
+} }));
vi.mock('@/session/CompanionProfileSheet', () => ({ CompanionProfileSheet: (props: unknown) => { h.profile = props; return null; } }));
vi.mock('@/session/useTeammateNavigation', () => ({ useTeammateNavigation: () => ({ chooseMode: h.chooseMode }) }));
vi.mock('@/chat/useCloudCompanion', () => ({ useCloudCompanionHome: () => h.cloud }));
@@ -56,6 +64,22 @@ beforeEach(() => {
});
afterEach(() => act(() => root.unmount()));
+// Unit regression: Duo's companion controls must live in the native bar, not a second row
+// below its status area. Existing navigation tests only exercised the in-content header.
+it('hosts the companion identity and actions in the system bar while keeping their behavior', async () => {
+ const onBack = vi.fn();
+ await act(async () => root.render(<CompanionHeader nativeHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}}
+ resource={resource} deviceId="pc" deviceName="PC" online onBack={onBack} onSearch={() => {}} />));
+ expect(host.querySelector('[data-toolbar="left"]')?.textContent).toContain('Cindy');
+ expect(host.querySelector('[data-testid="companion.header"]')).toBeNull();
+ await act(async () => button('companion.identity').click());
+ expect(h.glance.visible).toBe(true);
+ await act(async () => button('companion.settings').click());
+ expect(h.profile.visible).toBe(true);
+ await act(async () => button('companion.back').click());
+ expect(onBack).toHaveBeenCalledOnce();
+});
+
it('goes back from the chat instead of opening a drawer, opens 近况 from the avatar and the profile from settings', async () => {
const onBack = vi.fn(), onSearch = vi.fn();
await act(async () => root.render(<CompanionHeader sessionId="s1" onQuoteTodo={() => {}} onAskCompanion={() => {}} resource={resource} deviceId="pc" deviceName="PC" online onBack={onBack} onSearch={onSearch} />));
@@ -130,6 +154,7 @@ function PageHost({ bindings }) {
const { auth, deviceId, sessionId, companionResource, companionEntry, shareSelectionActive, setSearchOpen, goBackToHome, companionWorkingLabel, quoteTodoInComposer, askCompanionInComposer, canUseComposer, composerDraftHydrated } = bindings;
const currentSession = null;
const isSideChatSheet = false;
+ const horizontalSystemHeader = bindings.nativeHeader ?? false;
const companionSettingsRequest = bindings.companionSettingsRequest;
const deviceName = 'PC', remoteUnavailableReason = null, sessionListDrawerOverlayMounted = false;
${statements.slice(stateStart, stateEnd).map(n => n.getText(source)).join('\n')}
@@ -140,14 +165,14 @@ function PageHost({ bindings }) {
function StackScreen({ options }: { options: Record<string, unknown> }) { h.screenOptions.push(options); return null; }
const PageHost = new Function('React', 'useState', 'useHostManagedSession', 'CompanionHeader', 'StackScreen',
`${compiled}; return PageHost;`)({ createElement, Fragment }, useState, useHostManagedSession, CompanionHeader, StackScreen);
-const pageBindings = () => ({ auth: h.auth, deviceId: 'pc', sessionId: 'session-a', shareSelectionActive: false,
+const pageBindings = () => ({ auth: h.auth, deviceId: 'pc', sessionId: 'session-a', shareSelectionActive: false, nativeHeader: false,
companionEntry: { ready: true },
companionResource: { ref: { kind: 'bot', collectionId: 'bots', id: 'bot-a' }, display: { title: 'Cindy' } } as RemoteResource | null,
setSearchOpen: vi.fn(), goBackToHome: vi.fn(), companionWorkingLabel: null as string | null, quoteTodoInComposer: vi.fn(), askCompanionInComposer: vi.fn(), canUseComposer: true, composerDraftHydrated: true });
const showPage = (bindings: ReturnType<typeof pageBindings>) => act(async () => { root.render(<PageHost bindings={bindings} />); });
-it('wires the page: title while entry validation runs, Back to the roster, and the working breath', async () => {
- const bindings = pageBindings(); bindings.companionEntry.ready = false;
+it.each([false, true])('wires the page: entry validation, Back and working breath (native=%s)', async nativeHeader => {
+ const bindings = pageBindings(); bindings.nativeHeader = nativeHeader; bindings.companionEntry.ready = false;
await showPage(bindings);
expect(host.textContent).toContain('Cindy');
expect(button('companion.settings').disabled).toBe(true);
@@ -158,9 +183,9 @@ it('wires the page: title while entry validation runs, Back to the roster, and t
expect(host.querySelector('[data-testid="ring"]')).not.toBeNull();
await act(async () => button('companion.back').click());
expect(bindings.goBackToHome).toHaveBeenCalledOnce();
- // The companion row is the only header: the native bar the task header configured while the
- // entry resolved must not keep its title and sync spinner on top of the identity.
- expect(h.screenOptions).toContainEqual(expect.objectContaining({ headerShown: false, headerTitle: '' }));
+ // Replace the ordinary task title once the companion resolves, in either header host.
+ expect(h.screenOptions).toContainEqual(expect.objectContaining({ headerShown: nativeHeader, headerTitle: '' }));
+ if (nativeHeader) expect(h.screenOptions.some(options => options.headerShown === false)).toBe(false);
});
it('shows the ordinary task header on non-companion pages and while sharing', async () => {
@@ -233,4 +258,3 @@ it('offers no computer change for a companion without a known main computer', as
await act(async () => button('companion.settings').click());
expect(h.profile.onOpenHome).toBeUndefined();
});
-
diff --git a/apps/mobile/src/session/BotGroupChatScreen.tsx b/apps/mobile/src/session/BotGroupChatScreen.tsx
index 37f845679c..a9c4cb3462 100644
--- a/apps/mobile/src/session/BotGroupChatScreen.tsx
+++ b/apps/mobile/src/session/BotGroupChatScreen.tsx
@@ -21,6 +21,8 @@ import {
} from 'react-native';
import { showConfirm } from '@/platform/chrome';
import { Stack, useRouter } from 'expo-router';
+import { useHeaderHeight } from 'expo-router/react-navigation';
+import { useAdaptiveWindow } from '@/platform/AdaptiveWindowContext';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { useTranslation } from 'react-i18next';
import { resolveRemoteText } from '@cindy/device-link';
@@ -127,6 +129,9 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId }: { deviceId
// iOS: the header floats on the task header's feathered blur and the timeline scrolls beneath it.
const floatingHeader = Platform.OS === 'ios';
const insets = useSafeAreaInsets();
+ const window = useAdaptiveWindow();
+ const nativeHeader = floatingHeader && window.barEdge === 'none';
+ const nativeHeaderHeight = useHeaderHeight();
const [headerHeight, setHeaderHeight] = useState(0);
const stickToBottom = useRef(true);
const group = chat.state.kind === 'ready' ? chat.state.group : null;
@@ -296,7 +301,7 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId }: { deviceId
: cachedRow?.item.display.subtitle ? resolveRemoteText(cachedRow.item.display.subtitle, i18n.language) : '';
const headerMembers = group ? group.members.map((member) => identityFor(member.botId, member.name)) : [];
- const header = <ChatIdentityHeader testIDPrefix="botGroup" settingsTestID="botGroup.settingsButton"
+ const header = <ChatIdentityHeader testIDPrefix="botGroup" settingsTestID="botGroup.settingsButton" nativeHeader={nativeHeader}
mark={<BotGroupDuoAvatar deviceId={deviceId} members={headerMembers} online={chat.online} variant="header"
working={group?.round.status === 'running'} />}
title={title}
@@ -377,11 +382,11 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId }: { deviceId
}
return <SafeAreaView style={styles.screen} edges={floatingHeader ? ['left', 'right', 'bottom'] : ['top', 'left', 'right', 'bottom']} testID="botGroup.screen">
- <Stack.Screen options={{ headerShown: false }} />
+ {nativeHeader ? null : <Stack.Screen options={{ headerShown: false }} />}
{floatingHeader ? <>
<View style={[styles.flex, group ? null : { paddingTop: headerHeight }]}>{body}</View>
- <SessionHeaderNativeBlur height={Math.max(headerHeight, insets.top + navigationChrome.target)} fadeInside={CHAT_HEADER_BLUR_FADE_INSIDE} />
- <View style={[styles.floatingHeader, { paddingTop: insets.top }]} onLayout={(event) => setHeaderHeight(event.nativeEvent.layout.height)}>
+ <SessionHeaderNativeBlur height={Math.max(headerHeight, nativeHeader ? nativeHeaderHeight : insets.top + navigationChrome.target)} fadeInside={CHAT_HEADER_BLUR_FADE_INSIDE} />
+ <View style={[styles.floatingHeader, { paddingTop: nativeHeader ? nativeHeaderHeight : insets.top }]} onLayout={(event) => setHeaderHeight(event.nativeEvent.layout.height)}>
{header}
{offlineNote}
</View>
diff --git a/apps/mobile/src/session/ChatIdentityHeader.tsx b/apps/mobile/src/session/ChatIdentityHeader.tsx
index 1f68e34a59..dc4b47ff7d 100644
--- a/apps/mobile/src/session/ChatIdentityHeader.tsx
+++ b/apps/mobile/src/session/ChatIdentityHeader.tsx
@@ -1,10 +1,12 @@
-import type { ReactNode } from 'react';
-import { Keyboard, Pressable, StyleSheet, View } from 'react-native';
+import { useMemo, type ReactNode } from 'react';
+import { Keyboard, Pressable, StyleSheet, View, useWindowDimensions } from 'react-native';
+import { Stack } from 'expo-router';
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Settings2 } from 'lucide-react-native';
import { useTranslation } from 'react-i18next';
import { Text } from '@/components/AppText';
import { NativeChromeBackButton } from '@/platform/chrome/NativeChromeBackButton';
-import { fontWeight, iconSize, iconStroke, lineHeight, spacing, typeScale, useTheme, useThemedStyles, type ThemeColors } from '@/theme';
+import { fontWeight, iconSize, iconStroke, lineHeight, navigationChrome, spacing, typeScale, useTheme, useThemedStyles, type ThemeColors } from '@/theme';
import { HomeHeaderGlassButton } from './HomeHeaderGlassButton';
/** Identity mark size in chat headers: a 32pt avatar (1:1) or a 32pt two-member group mark. */
@@ -22,8 +24,10 @@ export const CHAT_HEADER_BLUR_FADE_INSIDE = 0;
* 设置。点身份区默认与设置按钮打开同一份资料 / 设置;伙伴私聊的身份区打开近况(onOpenIdentity)。
*/
export function ChatIdentityHeader({
- accessory, mark, title, subtitle, identityLabel, identityHint, controlsReady = true, onBack, onOpenSettings, onOpenIdentity, settingsLabel, testIDPrefix, settingsTestID,
+ nativeHeader = false, accessory, mark, title, subtitle, identityLabel, identityHint, controlsReady = true, onBack, onOpenSettings, onOpenIdentity, settingsLabel, testIDPrefix, settingsTestID,
}: {
+ /** The caller reserves the measured iOS navigation bar height, including the status area. */
+ nativeHeader?: boolean;
accessory?: ReactNode;
mark: ReactNode;
title: string;
@@ -49,10 +53,8 @@ export function ChatIdentityHeader({
const open = () => { if (controlsReady && onOpenSettings) { Keyboard.dismiss(); onOpenSettings(); } };
const identityAction = onOpenIdentity ?? onOpenSettings;
const openIdentity = () => { if (controlsReady && identityAction) { Keyboard.dismiss(); identityAction(); } };
- return <View style={styles.header} testID={`${testIDPrefix}.header`}>
- {/* Same system back as the task header. */}
- <NativeChromeBackButton testID={`${testIDPrefix}.back`} label={t('shared.back')} onPress={() => { Keyboard.dismiss(); onBack(); }} />
- <Pressable style={({ pressed }) => [styles.identity, pressed && styles.pressed]} accessibilityRole={identityAction ? 'button' : 'header'}
+ const back = <NativeChromeBackButton testID={`${testIDPrefix}.back`} label={t('shared.back')} onPress={() => { Keyboard.dismiss(); onBack(); }} />;
+ const identity = <Pressable style={({ pressed }) => [styles.identity, pressed && styles.pressed]} accessibilityRole={identityAction ? 'button' : 'header'}
accessibilityLabel={identityLabel} accessibilityHint={identityAction ? identityHint : undefined}
accessibilityState={identityAction ? { disabled: !controlsReady } : undefined}
disabled={!controlsReady || !identityAction} onPress={openIdentity} testID={`${testIDPrefix}.identity`}>
@@ -61,14 +63,42 @@ export function ChatIdentityHeader({
<Text numberOfLines={1} style={styles.title}>{title}</Text>
{typeof subtitle === 'string' ? <Text numberOfLines={1} style={styles.subtitle}>{subtitle}</Text> : subtitle}
</View>
- </Pressable>
- {accessory}
- {settings ? <HomeHeaderGlassButton testID={settingsTestID ?? `${testIDPrefix}.settings`} disabled={!controlsReady} accessibilityLabel={settingsLabel ?? ''} onPress={open}>
+ </Pressable>;
+ const actions = <>{accessory}{settings ? <HomeHeaderGlassButton testID={settingsTestID ?? `${testIDPrefix}.settings`} disabled={!controlsReady} accessibilityLabel={settingsLabel ?? ''} onPress={open}>
<Settings2 size={iconSize.lg} strokeWidth={CHAT_HEADER_GLYPH_STROKE} color={colors.textPrimary} />
- </HomeHeaderGlassButton> : null}
+ </HomeHeaderGlassButton> : null}</>;
+ if (nativeHeader) return <NativeChatHeader identity={identity} back={back} actions={actions} actionCount={Number(settings) + Number(!!accessory)} />;
+ return <View style={styles.header} testID={`${testIDPrefix}.header`}>
+ {back}{identity}{actions}
</View>;
}
+/** Keep controls inside UIKit's hit surface when Duo shares navigation with the status row. */
+function NativeChatHeader({ identity, back, actions, actionCount }: {
+ identity: ReactNode; back: ReactNode; actions: ReactNode; actionCount: number;
+}) {
+ const { colors } = useTheme();
+ const window = useWindowDimensions();
+ const insets = useSafeAreaInsets();
+ const width = Math.max(0, Math.min(240, window.width - insets.left - insets.right
+ - (navigationChrome.target * Math.max(1, actionCount) + spacing.lg * 2 + spacing.md) * 2));
+ const options = useMemo(() => ({ headerShown: true, headerTransparent: true, headerShadowVisible: false,
+ headerBackVisible: false, headerTintColor: colors.textPrimary,
+ headerStyle: { backgroundColor: 'transparent' }, headerTitle: '',
+ }), [colors.textPrimary]);
+ return <>
+ <Stack.Screen options={options} />
+ <Stack.Toolbar placement="left"><Stack.Toolbar.View hidesSharedBackground>
+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: spacing.md }}>
+ {back}<View style={{ width, height: navigationChrome.target }}>{identity}</View>
+ </View>
+ </Stack.Toolbar.View></Stack.Toolbar>
+ {actionCount > 0 ? <Stack.Toolbar placement="right"><Stack.Toolbar.View hidesSharedBackground>
+ <View style={{ flexDirection: 'row', gap: spacing.md }}>{actions}</View>
+ </Stack.Toolbar.View></Stack.Toolbar> : null}
+ </>;
+}
+
/** Subtitle text in the header's style, for callers that compose it with a leading mark. */
export function ChatIdentitySubtitle({ children }: { children: string }) {
const styles = useThemedStyles(makeStyles);
diff --git a/apps/mobile/src/session/CloudCompanionScreen.tsx b/apps/mobile/src/session/CloudCompanionScreen.tsx
index 8497dc74c4..5badd2962d 100644
--- a/apps/mobile/src/session/CloudCompanionScreen.tsx
+++ b/apps/mobile/src/session/CloudCompanionScreen.tsx
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
-import { ActivityIndicator, ScrollView, StyleSheet, View, type NativeScrollEvent, type NativeSyntheticEvent } from 'react-native';
+import { ActivityIndicator, Platform, ScrollView, StyleSheet, View, type NativeScrollEvent, type NativeSyntheticEvent } from 'react-native';
import { Stack, useRouter } from 'expo-router';
+import { useHeaderHeight } from 'expo-router/react-navigation';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useTranslation } from 'react-i18next';
import { useAuth } from '@/auth/AuthContext';
@@ -55,7 +56,9 @@ export function CloudCompanionScreen({ actorId, botId, deviceId, deviceName, tit
}) {
const { t } = useTranslation();
const { colors } = useTheme();
- const { width } = useAdaptiveWindow();
+ const { width, barEdge } = useAdaptiveWindow();
+ const nativeHeader = Platform.OS === 'ios' && barEdge === 'none';
+ const nativeHeaderHeight = useHeaderHeight();
const answerLayout = useMemo(() => buildMessageContentLayout({ screenWidth: width }), [width]);
const styles = useThemedStyles(makeStyles);
const router = useRouter();
@@ -225,9 +228,10 @@ export function CloudCompanionScreen({ actorId, botId, deviceId, deviceName, tit
}
const busy = loadingDevices || switching.phase === 'requesting';
- return <SafeAreaView style={styles.screen} edges={['top', 'left', 'right', 'bottom']} testID="cloudCompanion.screen">
- <Stack.Screen options={{ headerShown: false }} />
- <ChatIdentityHeader testIDPrefix="cloudCompanion"
+ return <SafeAreaView style={[styles.screen, nativeHeader && { paddingTop: nativeHeaderHeight }]}
+ edges={nativeHeader ? ['left', 'right', 'bottom'] : ['top', 'left', 'right', 'bottom']} testID="cloudCompanion.screen">
+ {nativeHeader ? null : <Stack.Screen options={{ headerShown: false }} />}
+ <ChatIdentityHeader testIDPrefix="cloudCompanion" nativeHeader={nativeHeader}
mark={avatar(CHAT_HEADER_MARK_SIZE)}
title={name}
subtitle={<View style={styles.subtitleRow}>
diff --git a/apps/mobile/src/session/CompanionHeader.tsx b/apps/mobile/src/session/CompanionHeader.tsx
index 3ad54a53bb..c74ddaa708 100644
--- a/apps/mobile/src/session/CompanionHeader.tsx
+++ b/apps/mobile/src/session/CompanionHeader.tsx
@@ -27,6 +27,7 @@ const DUE_DOT = 7;
* 有没看过的到期待办时头像右上亮小红点,打开近况即灭。
*/
export function CompanionHeader(props: {
+ nativeHeader?: boolean;
resource: RemoteResource; deviceId: string; deviceName: string; online: boolean; controlsReady?: boolean;
/** The companion is working on a reply (the avatar breathes). */
working?: boolean;
@@ -45,7 +46,7 @@ export function CompanionHeader(props: {
return <CompanionHeaderContent key={accountGeneration} {...props} />;
}
-function CompanionHeaderContent({ resource, deviceId, deviceName, online, controlsReady = true, working = false, sessionId, onQuoteTodo, onAskCompanion, askCompanionReady = true, onSearch, onBack, settingsRequest }: Parameters<typeof CompanionHeader>[0]) {
+function CompanionHeaderContent({ nativeHeader, resource, deviceId, deviceName, online, controlsReady = true, working = false, sessionId, onQuoteTodo, onAskCompanion, askCompanionReady = true, onSearch, onBack, settingsRequest }: Parameters<typeof CompanionHeader>[0]) {
const { t, i18n } = useTranslation();
const styles = useThemedStyles(makeStyles);
const navigation = useTeammateNavigation();
@@ -70,7 +71,7 @@ function CompanionHeaderContent({ resource, deviceId, deviceName, online, contro
// contact); a message that cannot get through is what asks to switch computers.
const connection = online || homed ? '' : t('devices.resources.hostOffline');
return <>
- <ChatIdentityHeader testIDPrefix="companion"
+ <ChatIdentityHeader testIDPrefix="companion" nativeHeader={nativeHeader}
mark={<>
<RemoteCompanionAvatar avatar={resource.display.avatar} name={name} deviceId={deviceId} online={online} size={CHAT_HEADER_MARK_SIZE} framed />
<CompanionPresenceRing active={working} width={1.5} />