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。

feat(mobile): 统一 iOS 首页与聊天顶栏,任务/伙伴左右滑动切换

kirozengbf8bddc15204
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index 422242e99a..c07440a002 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -22,6 +22,7 @@ import { FailedScheduleNotice } from '@/session/FailedScheduleNotice';
import { shouldShowFailedScheduleNotice, type FailedScheduleRunSnapshot } from '@cindy/maker-shared/schedule-model';
import type { TokenSpeedSnapshot } from '@cindy/maker-shared/usage-format';
import { CompanionHeader } from '@/session/CompanionHeader';
+import { CHAT_HEADER_BLUR_FADE_INSIDE } from '@/session/ChatIdentityHeader';
import { useHiddenHistoryChase } from '@/session/hiddenHistoryChase';
import { collectCompanionPluginInvocations } from '@/session/pluginInvocations';
import { COMPANION_STATUS_AVATAR_SIZE, CompanionWorkingStatus, useCompanionDisplayResource, useCompanionWorkingLabel } from '@/session/CompanionWorkingStatus';
@@ -9419,10 +9420,11 @@ function SessionScreenContent() {
const dockKeyboardFollow = Platform.OS === 'ios' && composerDock.enabled && nativeComposerFrameAvailable
&& adaptiveWindow.regions.length === 0 && sessionOperationLayout.composerSlot === 'editable'
&& !shareSelectionActive && !isSharedTaskAccessRevoked;
+ const companionHeaderShown = companionChat && !!companionResource && !shareSelectionActive;
const headerNode = (
<>
<Stack.Screen options={{ gestureEnabled: !sessionListDrawerOverlayMounted }} />
- {companionChat && companionResource && !shareSelectionActive ? <>
+ {companionHeaderShown ? <>
<Stack.Screen options={COMPANION_NATIVE_HEADER_OPTIONS} />
<CompanionHeader key={`${auth.accountGeneration}:${deviceId}:${companionResource.ref.id}`}
resource={companionResource} deviceId={deviceId} deviceName={deviceName} online={!remoteUnavailableReason} controlsReady={companionEntry.ready}
@@ -9506,7 +9508,8 @@ function SessionScreenContent() {
style={[styles.keyboard, { marginLeft: paneLayout.detail.x, marginRight: Math.max(0, windowDimensions.width - paneLayout.detail.x - paneLayout.detail.width) }]}
>
{Platform.OS === 'ios' ? (
- <SessionHeaderNativeBlur height={Math.max(topOverlayHeight, insets.top + 44)} />
+ <SessionHeaderNativeBlur height={Math.max(topOverlayHeight, insets.top + 44)}
+ fadeInside={companionHeaderShown ? CHAT_HEADER_BLUR_FADE_INSIDE : undefined} />
) : null}
<SessionChromeLayer
hiddenFromAccessibility={sessionListDrawerOverlayMounted}
@@ -9521,7 +9524,8 @@ function SessionScreenContent() {
<BlurBackdrop intensity={50} overlayColor={colors.surfaceTranslucent} />
</View>
) : null}
- <View style={[styles.sessionChromeContent, { paddingTop: horizontalSystemHeader ? nativeHeaderHeight : insets.top + (paneLayout.persistent ? spacing.lg : 0) }, companionChat && { backgroundColor: colors.surface }]}>
+ {/* iOS chat headers sit on the task header's feathered blur; an opaque band left a hard edge. */}
+ <View style={[styles.sessionChromeContent, { paddingTop: horizontalSystemHeader ? nativeHeaderHeight : insets.top + (paneLayout.persistent ? spacing.lg : 0) }, companionChat && Platform.OS !== 'ios' && { backgroundColor: colors.surface }]}>
{headerNode}
{!isSharedTaskAccessRevoked && (showConnectionBanner || showCachedHistoryNotice) ? (
diff --git a/apps/mobile/assets/navigation/README.md b/apps/mobile/assets/navigation/README.md
index d729cb9f04..9cc6057243 100644
--- a/apps/mobile/assets/navigation/README.md
+++ b/apps/mobile/assets/navigation/README.md
@@ -7,3 +7,13 @@ Monitor and Folder geometry,
without substituting an SF Symbol or losing Duo's native vertical placement.
Metro bundles these JS-referenced assets; no native asset catalog change.
Lucide's ISC license is included in LICENSE.
+
+The home menu uses menu.svg and menu-attention.svg. Both have the same 26pt
+transparent canvas, with the existing narrow 20pt glyph centered inside it
+(13.5pt horizontal paths, 2pt round strokes, matching the regular icon weight).
+The endpoints are inset by 0.25pt to preserve the approved 15.5pt visible width. Only the attention state adds a
+6pt-diameter dot at the upper right. The glyph never moves when attention changes.
+The native toolbar tints the template; Duo's custom 44pt button uses the same
+artwork and semantic tint. Do not use an empty Stack.Toolbar.Badge: the iOS
+header bridge constructs a text badge even for an empty value, producing an
+oversized circle. These are JS-bundled images, not native asset-catalog inputs.
diff --git a/apps/mobile/assets/navigation/menu-attention.png b/apps/mobile/assets/navigation/menu-attention.png
new file mode 100644
index 0000000000..fe9617bb04
Binary files /dev/null and b/apps/mobile/assets/navigation/menu-attention.png differ
diff --git a/apps/mobile/assets/navigation/menu-attention.svg b/apps/mobile/assets/navigation/menu-attention.svg
new file mode 100644
index 0000000000..568cd0d7fd
--- /dev/null
+++ b/apps/mobile/assets/navigation/menu-attention.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26"><g transform="translate(3 3)" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><path d="M3.25 4.5h13.5M3.25 10h13.5M3.25 15.5h13.5"/></g><circle cx="23" cy="3" r="3" fill="black"/></svg>
diff --git a/apps/mobile/assets/navigation/[email protected] b/apps/mobile/assets/navigation/[email protected]
new file mode 100644
index 0000000000..2dc19e3ba9
Binary files /dev/null and b/apps/mobile/assets/navigation/[email protected] differ
diff --git a/apps/mobile/assets/navigation/[email protected] b/apps/mobile/assets/navigation/[email protected]
new file mode 100644
index 0000000000..18b2e18edb
Binary files /dev/null and b/apps/mobile/assets/navigation/[email protected] differ
diff --git a/apps/mobile/assets/navigation/menu.png b/apps/mobile/assets/navigation/menu.png
new file mode 100644
index 0000000000..43cd4b2c89
Binary files /dev/null and b/apps/mobile/assets/navigation/menu.png differ
diff --git a/apps/mobile/assets/navigation/menu.svg b/apps/mobile/assets/navigation/menu.svg
new file mode 100644
index 0000000000..157dc86c8a
--- /dev/null
+++ b/apps/mobile/assets/navigation/menu.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26"><g transform="translate(3 3)" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><path d="M3.25 4.5h13.5M3.25 10h13.5M3.25 15.5h13.5"/></g></svg>
diff --git a/apps/mobile/assets/navigation/[email protected] b/apps/mobile/assets/navigation/[email protected]
new file mode 100644
index 0000000000..682fda1b05
Binary files /dev/null and b/apps/mobile/assets/navigation/[email protected] differ
diff --git a/apps/mobile/assets/navigation/[email protected] b/apps/mobile/assets/navigation/[email protected]
new file mode 100644
index 0000000000..25f121082d
Binary files /dev/null and b/apps/mobile/assets/navigation/[email protected] differ
diff --git a/apps/mobile/docs/mobile-design-guide.md b/apps/mobile/docs/mobile-design-guide.md
index 43f48c1a10..35eeea2add 100644
--- a/apps/mobile/docs/mobile-design-guide.md
+++ b/apps/mobile/docs/mobile-design-guide.md
@@ -221,6 +221,11 @@ function Foo() {
### iOS 外壳 vs Cindy 内容
+- **任务/伙伴切换**:按左任务、右伙伴的顺序做同一套横向滑动转场,抽屉和标题下拉选择都复用 HomeModePanes;不重建已访问列表,不丢搜索或滚动位置。滑动用不回弹的临界阻尼弹簧(参数见 DESIGN.md §14.4),快速反向切换从当前位置继续;系统减弱动态效果或尚未取得该偏好时直接切换。导航栏和顶部模糊固定不动,模糊由 HomeModePanes 统一绘制一层。
+- **首页菜单提示点**:可见圆点直径 6pt,原生工具栏用同尺寸画布的有点/无点模板图,避免空的数字徽章被系统放大。图标位置、按钮外框和点击范围不随提示点出现而变化。
+
+- **首页导航共用组件(2026-10-13)**:iOS 任务与伙伴首页都调用 platform/chrome/HomeStackHeader,统一系统导航栏、菜单按钮与居中标题宽度;顶部模糊背景由 HomeModePanes 在滑动层外统一绘制。页面只提供标题内容、菜单动作和右侧工具;仅当前可见首页注册导航栏。伙伴标题允许独立对齐,目前保持居中;任务标题保留长名称避让。伙伴列表、安全区、滚动指示器和下拉刷新只计算一次顶部占位。普通页面、聊天身份栏、面板及 Android 导航暂未纳入这一批,不视为全端迁移完成。
+
iOS 新增与改造界面遵循 [iOS 原生界面规范](../../../docs/design-rules/ios-native-design.md)。该规范区分系统容器、原生控件和 Cindy 业务内容;取代原先“复杂内容面板一律使用 SheetSurface”的规定。
- 首页和简单页继续使用系统导航栏。任务页采用原生操作控件与透明标题布局,按首页实际导航中心对齐;保留返回锚点及 testID。
diff --git a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx
index 34d806188c..96c9b3a099 100644
--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx
+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx
@@ -23,7 +23,7 @@ const h = vi.hoisted(() => ({
discarded: [] as any[],
deleted: [] as string[],
keyboardAvoidingView: null as any,
- platform: { OS: 'ios' },
+ platform: { OS: 'ios' }, headerBlur: [] as number[], headerFade: [] as (number | undefined)[],
}));
vi.mock('expo-web-browser', () => ({ openBrowserAsync: vi.fn(async () => ({})) }));
@@ -61,7 +61,8 @@ vi.mock('expo-router', () => ({
useRouter: () => ({ back: vi.fn(), replace: vi.fn() }),
useFocusEffect: (effect: () => void) => useEffect(effect, [effect]),
}));
-vi.mock('react-native-safe-area-context', () => ({ SafeAreaView: ({ children }: any) => el('main', null, children) }));
+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) => ({
...await importOriginal<typeof import('react-i18next')>(),
useTranslation: () => ({
@@ -266,7 +267,7 @@ beforeEach(() => {
h.management = null;
vi.clearAllMocks();
h.uuid = 0; h.inputs = {}; h.teammateQuery = ''; h.teammates = { rows: [], loading: false, failed: false };
- h.platform.OS = 'ios'; h.keyboardAvoidingView = null;
+ h.platform.OS = 'ios'; h.keyboardAvoidingView = null; h.headerBlur = []; h.headerFade = [];
h.chat = { reload: vi.fn(), act: vi.fn(async () => ({ effects: [] })), online: true };
h.discarded = []; h.deleted = [];
h.local = {
@@ -285,6 +286,15 @@ describe('group timeline', () => {
h.platform.OS = 'android';
await render();
expect(h.keyboardAvoidingView).toMatchObject({ enabled: true, behavior: 'height' });
+ expect(h.headerBlur).toEqual([]);
+ });
+
+ 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);
+ // The two-line identity stays over solid blur; the feather starts at the header's lower edge.
+ expect(h.headerFade.at(-1)).toBe(0);
});
it('waits for measured tail positioning before acknowledging replies, including new snapshots', async () => {
diff --git a/apps/mobile/src/__tests__/BotGroupList.test.tsx b/apps/mobile/src/__tests__/BotGroupList.test.tsx
index fa3f5c9d14..4fc6ba31d4 100644
--- a/apps/mobile/src/__tests__/BotGroupList.test.tsx
+++ b/apps/mobile/src/__tests__/BotGroupList.test.tsx
@@ -13,6 +13,11 @@ const h = vi.hoisted(() => ({
nativeMenu: true,
}));
+vi.mock('expo-router', () => ({ Stack: { Toolbar: Object.assign(({ children }: any) => children, {
+ Button: (props: any) => el('button', { onClick: props.onPress }, props.accessibilityLabel),
+ Menu: ({ children }: any) => children,
+ MenuAction: (props: any) => el('button', { onClick: props.onPress, disabled: props.disabled }, props.children),
+}) } }));
vi.mock('react-native', () => {
const box = ({ children, testID, accessibilityLabel }: any) => el('div', { 'data-testid': testID, 'aria-label': accessibilityLabel }, children);
return {
diff --git a/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx b/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx
index 8c84d1af2e..f3a848c8ce 100644
--- a/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx
+++ b/apps/mobile/src/__tests__/CompanionHeaderNavigation.test.tsx
@@ -119,6 +119,7 @@ function PageHost({ bindings }) {
const companionSettingsRequest = bindings.companionSettingsRequest;
const deviceName = 'PC', remoteUnavailableReason = null, sessionListDrawerOverlayMounted = false;
${statements.slice(stateStart, stateEnd).map(n => n.getText(source)).join('\n')}
+ ${statements[declaration('companionHeaderShown')].getText(source)}
${relevantJsx(header)}
return <div data-testid="page-route">{headerNode}</div>;
}`, { compilerOptions: { target: ts.ScriptTarget.ES2022, jsx: ts.JsxEmit.React } }).outputText;
diff --git a/apps/mobile/src/__tests__/HomeModePanes.test.tsx b/apps/mobile/src/__tests__/HomeModePanes.test.tsx
index a5d6e15f41..866d20f63f 100644
--- a/apps/mobile/src/__tests__/HomeModePanes.test.tsx
+++ b/apps/mobile/src/__tests__/HomeModePanes.test.tsx
@@ -1,10 +1,40 @@
// @vitest-environment jsdom
-import { act, createElement, useState, useEffect } from 'react';
+import { act, createElement, useState, useEffect, type ReactNode } from 'react';
import { createRoot } from 'react-dom/client';
-import { describe, expect, it, vi } from 'vitest';
-vi.mock('react-native', () => ({ View: ({ children, style, testID }: any) => createElement('div', { style, 'data-testid': testID }, children) }));
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+const h = vi.hoisted(() => ({ reduced: false as boolean | null, width: 400, header: 106, blur: [] as number[], progress: null as any,
+ styles: [] as (() => any)[], spring: vi.fn((target: number, _config: unknown) => target), cancel: vi.fn() }));
+vi.mock('react-native', () => ({
+ View: ({ children, testID, pointerEvents, accessibilityElementsHidden }: any) =>
+ createElement('div', { 'data-testid': testID, 'data-pointer': pointerEvents, 'data-hidden': accessibilityElementsHidden }, children),
+ StyleSheet: { create: (value: unknown) => value, absoluteFill: {} },
+}));
+vi.mock('@/hooks/useReduceMotion', () => ({ useReduceMotionEnabled: () => h.reduced }));
+vi.mock('@/platform/AdaptiveWindowContext', () => ({ useAdaptiveWindow: () => ({ width: h.width }) }));
+vi.mock('@/session/useOptionalHeaderHeight', () => ({ useOptionalHeaderHeight: () => h.header }));
+vi.mock('@/session/SessionHeaderNativeControls', () => ({ SessionHeaderNativeBlur: ({ height }: any) => {
+ h.blur.push(height); return createElement('div', { 'data-testid': 'fixed-blur' });
+} }));
+vi.mock('react-native-reanimated', async () => {
+ const { useRef } = await import('react'); const { View } = await import('react-native');
+ return { default: { View }, useSharedValue: (value: number) => { const ref = useRef({ value }); h.progress = ref.current; return ref.current; },
+ useAnimatedStyle: (factory: () => any) => { h.styles.push(factory); return factory(); },
+ cancelAnimation: h.cancel, withSpring: h.spring,
+ };
+});
import { HomeModePanes } from '@/session/HomeModePanes';
+import { HOME_MODE_SLIDE_SPRING, HomeModeProgressContext, useHomeModeProgress } from '@/session/HomeModeTransition';
+import type { HomeMode } from '@/session/homeViewPreferenceStore';
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
+beforeEach(() => { h.reduced = false; h.styles = []; h.blur = []; h.spring.mockClear(); h.cancel.mockClear(); h.width = 400; });
+
+/** Production wiring: ResidentHomeListProvider owns the clock, the panes only read it. */
+function Home({ mode, animate = true, ready = true, tasks = 'tasks', teammates = 'teammates' }: {
+ mode: HomeMode; animate?: boolean; ready?: boolean; tasks?: ReactNode; teammates?: ReactNode;
+}) {
+ const progress = useHomeModeProgress(mode, animate, ready);
+ return createElement(HomeModeProgressContext.Provider, { value: progress }, createElement(HomeModePanes, { mode, tasks, teammates }));
+}
describe('home mode continuity', () => {
it('keeps task search, expansion and scroll state mounted through repeated mode switches', () => {
const mount = vi.fn(); const unmount = vi.fn();
@@ -17,7 +47,7 @@ describe('home mode continuity', () => {
createElement('span', {}, `${query}:${expanded}`));
}
const container = document.createElement('div'); const root = createRoot(container);
- const render = (mode: 'tasks' | 'teammates') => act(() => root.render(createElement(HomeModePanes, { mode, tasks: createElement(Tasks), teammates: createElement('span', {}, 'roster') })));
+ const render = (mode: 'tasks' | 'teammates') => act(() => root.render(createElement(Home, { mode, tasks: createElement(Tasks), teammates: createElement('span', {}, 'roster') })));
try {
render('tasks'); act(() => container.querySelector('button')!.click());
const taskElement = container.querySelector('[data-tasks]')!; taskElement.scrollTop = 120;
@@ -28,3 +58,52 @@ describe('home mode continuity', () => {
} finally { act(() => root.unmount()); }
});
});
+
+it('slides toward the right-hand teammate tab and retargets a reversal without cancelling the running spring', () => {
+ const node = document.createElement('div'); const root = createRoot(node);
+ const render = (mode: HomeMode) => act(() => root.render(createElement(Home, { mode })));
+ try {
+ render('tasks'); expect(h.spring).not.toHaveBeenCalled();
+ render('teammates'); expect(h.spring).toHaveBeenLastCalledWith(1, HOME_MODE_SLIDE_SPRING);
+ // Sample the same shared progress partway through the UI-thread animation.
+ h.progress.value = 0.4;
+ const [tasks, teammates] = h.styles.slice(-2);
+ expect(tasks().transform[0].translateX).toBe(-160);
+ expect(teammates().transform[0].translateX).toBe(240);
+ expect(node.querySelector('[data-testid="home.pane.tasks"]')?.getAttribute('data-pointer')).toBe('none');
+ expect(node.querySelector('[data-testid="home.pane.tasks"]')?.getAttribute('data-hidden')).toBe('true');
+ render('tasks'); expect(h.spring).toHaveBeenLastCalledWith(0, HOME_MODE_SLIDE_SPRING);
+ expect(h.cancel).not.toHaveBeenCalled();
+ h.width = 600; render('tasks'); h.progress.value = 0.5;
+ expect(h.styles.slice(-2).map(factory => factory().transform[0].translateX)).toEqual([-300, 300]);
+ } finally { act(() => root.unmount()); }
+ expect(h.cancel).toHaveBeenCalledOnce();
+});
+it('draws one bar blur outside the sliding panes', () => {
+ const node = document.createElement('div'); const root = createRoot(node);
+ try {
+ act(() => root.render(createElement(Home, { mode: 'teammates' })));
+ expect(node.querySelectorAll('[data-testid="fixed-blur"]')).toHaveLength(1);
+ expect(node.querySelector('[data-testid^="home.pane."] [data-testid="fixed-blur"]')).toBeNull();
+ expect(h.blur.at(-1)).toBe(106);
+ } finally { act(() => root.unmount()); }
+});
+it.each([
+ ['reduced motion', { reduced: true }], ['unknown motion preference', { reduced: null }],
+ ['a non-home route', { animate: false }], ['preference restoration', { ready: false }],
+] as const)('snaps for %s', (_name, options) => {
+ h.reduced = 'reduced' in options ? options.reduced : false;
+ const props = { animate: 'animate' in options ? options.animate : true, ready: 'ready' in options ? options.ready : true };
+ const root = createRoot(document.createElement('div'));
+ const render = (mode: HomeMode) => act(() => root.render(createElement(Home, { mode, ...props })));
+ try { render('tasks'); render('teammates'); expect(h.progress.value).toBe(1); expect(h.spring).not.toHaveBeenCalled(); }
+ finally { act(() => root.unmount()); }
+});
+it('snaps the first change after restoring the preference, then animates', () => {
+ const root = createRoot(document.createElement('div'));
+ const render = (mode: HomeMode, ready: boolean) => act(() => root.render(createElement(Home, { mode, ready })));
+ try {
+ render('tasks', false); render('teammates', true); expect(h.spring).not.toHaveBeenCalled();
+ render('tasks', true); expect(h.spring).toHaveBeenLastCalledWith(0, HOME_MODE_SLIDE_SPRING);
+ } finally { act(() => root.unmount()); }
+});
diff --git a/apps/mobile/src/__tests__/HomeStackHeader.test.tsx b/apps/mobile/src/__tests__/HomeStackHeader.test.tsx
new file mode 100644
index 0000000000..189a9e3c1a
--- /dev/null
+++ b/apps/mobile/src/__tests__/HomeStackHeader.test.tsx
@@ -0,0 +1,71 @@
+// @vitest-environment jsdom
+import { act, createElement as el } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+
+const h = vi.hoisted(() => ({ options: {} as any, dark: false }));
+vi.mock('react-native', () => ({
+ StyleSheet: { create: (value: unknown) => value }, Image: ({ source, style }: any) => el('i', { 'data-artwork': source, style }),
+ View: ({ children, testID }: any) => el('div', { 'data-testid': testID }, children),
+}));
+vi.mock('expo-router', () => ({ Stack: {
+ Screen: ({ options }: any) => { h.options = options; return options.headerTitle(); },
+ Header: () => null,
+ Toolbar: Object.assign(({ children }: any) => children, {
+ View: ({ children }: any) => el('div', { 'data-testid': 'custom-toolbar-item' }, children),
+ Button: ({ children, icon, onPress, accessibilityLabel }: any) => el('button', {
+ 'data-icon': icon, 'aria-label': accessibilityLabel, onClick: onPress,
+ }, children),
+ }),
+} }));
+vi.mock('@/platform/chrome/homeMenuIcon', () => ({ homeMenuIcon: 'narrow-home-menu', homeMenuAttentionIcon: 'small-dot-home-menu', homeMenuArtworkSize: 26 }));
+vi.mock('@/theme', async () => {
+ const { lightColors, darkColors } = await import('@/theme/tokens');
+ return { useTheme: () => ({ colors: h.dark ? darkColors : lightColors }) };
+});
+vi.mock('@/session/HomeHeaderGlassButton', () => ({ HomeHeaderGlassButton: ({ onPress, testID, accessibilityLabel, children }: any) =>
+ el('button', { onClick: onPress, 'data-testid': testID, 'aria-label': accessibilityLabel }, children) }));
+import { HomeStackHeader } from '@/platform/chrome/HomeStackHeader';
+import { lightColors, darkColors } from '@/theme/tokens';
+
+let root: Root;
+let node: HTMLDivElement;
+beforeEach(() => {
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
+ h.dark = false;
+ node = document.createElement('div'); root = createRoot(node);
+});
+afterEach(async () => { await act(async () => root.unmount()); });
+
+it.each([false, true])('keeps the native menu, neutral attention and title content across themes (dark=%s)', async dark => {
+ h.dark = dark;
+ const open = vi.fn();
+ await act(async () => root.render(el(HomeStackHeader, {
+ title: el('span', null, '伙伴'), menuA11y: 'Open menu, 3 tasks', menuTestID: 'teammates.navigation', onOpenMenu: open, attention: true,
+ })));
+ expect(node.textContent).toContain('伙伴');
+ expect(h.options.headerTransparent).toBe(true);
+ expect(h.options.headerTintColor).toBe((dark ? darkColors : lightColors).textPrimary);
+ expect(node.querySelector('button')?.getAttribute('data-icon')).toBe('small-dot-home-menu');
+ expect(node.querySelector('[data-testid="custom-toolbar-item"]')).toBeNull();
+ expect(node.querySelector('button')?.getAttribute('aria-label')).toBe('Open menu, 3 tasks');
+ await act(async () => node.querySelector('button')!.click());
+ expect(open).toHaveBeenCalledOnce();
+ await act(async () => root.render(el(HomeStackHeader, {
+ title: el('span', null, 'All tasks'), menuA11y: 'Open menu', menuTestID: 'home.chromeMenu', onOpenMenu: open,
+ })));
+ expect(node.textContent).toContain('All tasks');
+ expect(node.querySelector('button')?.getAttribute('data-icon')).toBe('narrow-home-menu');
+});
+
+it('keeps the Duo custom menu within the native toolbar and preserves its action', async () => {
+ const open = vi.fn();
+ await act(async () => root.render(el(HomeStackHeader, {
+ title: el('span', null, '伙伴'), menuA11y: 'Open menu', menuTestID: 'teammates.navigation', onOpenMenu: open,
+ keepMenuTopLeft: true, attention: true,
+ })));
+ const toolbar = node.querySelector('[data-testid="custom-toolbar-item"]')!;
+ expect(toolbar.querySelector('[data-artwork]')?.getAttribute('data-artwork')).toBe('small-dot-home-menu');
+ await act(async () => toolbar.querySelector('button')!.click());
+ expect(open).toHaveBeenCalledOnce();
+});
diff --git a/apps/mobile/src/__tests__/TeammateCreateButton.test.tsx b/apps/mobile/src/__tests__/TeammateCreateButton.test.tsx
index 822b7c7f56..2da238c218 100644
--- a/apps/mobile/src/__tests__/TeammateCreateButton.test.tsx
+++ b/apps/mobile/src/__tests__/TeammateCreateButton.test.tsx
@@ -2,7 +2,12 @@
import { act, createElement } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
-const h = vi.hoisted(() => ({ account: 1, button: {} as any, menu: {} as any, sheet: null as any, created: vi.fn(), alert: vi.fn() }));
+const h = vi.hoisted(() => ({ account: 1, button: {} as any, menu: {} as any, sheet: null as any, groupSheet: null as any, groupCreated: vi.fn(), created: vi.fn(), alert: vi.fn() }));
+vi.mock('expo-router', () => ({ Stack: { Toolbar: Object.assign(({ children }: any) => children, {
+ Button: (props: any) => createElement('button', { onClick: props.onPress }, props.accessibilityLabel),
+ Menu: ({ children, title, accessibilityLabel }: any) => createElement('section', { 'aria-label': title ?? accessibilityLabel }, children),
+ MenuAction: (props: any) => createElement('button', { onClick: props.onPress, disabled: props.disabled }, props.children),
+}) } }));
vi.mock('react-native', () => ({ Alert: { alert: h.alert } }));
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
vi.mock('lucide-react-native', () => ({ Plus: () => null }));
@@ -16,12 +21,13 @@ vi.mock('@/session/CompanionProfileSheet', () => ({ CompanionCreateSheet: (props
vi.mock('@/session/useTeammateRoster', () => ({ TEAMMATE_COLLECTION_ID: 'teammates' }));
vi.mock('@/hooks/useReduceMotion', () => ({ useReduceMotionEnabled: () => true }));
vi.mock('@/components/MobilePrimitives', () => ({ MainWindowActionButton: () => null }));
-vi.mock('@/session/BotGroupCreateSheet', () => ({ BotGroupCreateSheet: () => null }));
+vi.mock('@/session/BotGroupCreateSheet', () => ({ BotGroupCreateSheet: (props: any) => { h.groupSheet = props; return null; } }));
import { TeammateCreateButton } from '@/session/TeammateCreateButton';
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
const hosts = [{ deviceId: 'mac', deviceName: 'Mac' }, { deviceId: 'pc', deviceName: 'PC' }];
const ref = { collectionId: 'teammates', kind: 'bot', id: 'confirmed' };
let root: Root | undefined;
+let node: HTMLDivElement;
async function render(targets = hosts) { root ??= createRoot(document.createElement('div')); await act(async () => root!.render(createElement(TeammateCreateButton, { targets, preferredDeviceId: 'pc', onCreated: h.created }))); }
beforeEach(() => { vi.clearAllMocks(); h.account = 1; h.sheet = null; });
afterEach(() => { act(() => root?.unmount()); root = undefined; });
@@ -43,3 +49,34 @@ it('fences late native menu and create dismissal callbacks after account replace
h.account++; await render();
await act(async () => { oldMenu.onAction('pc'); oldSheet.onClosed(); }); expect(h.created).not.toHaveBeenCalled();
});
+
+async function toolbar(targets = hosts, groupTargets = [] as typeof hosts) {
+ if (!root) { node = document.createElement('div'); root = createRoot(node); }
+ await act(async () => root!.render(createElement(TeammateCreateButton, {
+ targets, groupTargets, appearance: 'toolbar', preferredDeviceId: 'pc', onCreated: h.created, onGroupCreated: h.groupCreated,
+ })));
+}
+it('native toolbar dispatches the selected host and preserves delayed creation receipts', async () => {
+ await toolbar();
+ expect([...node.querySelectorAll('button')].map(button => button.textContent)).toEqual(['PC', 'Mac']);
+ await act(async () => node.querySelector('button')!.click());
+ expect(h.sheet.deviceId).toBe('pc');
+ await act(async () => { h.sheet.onCreated(ref); h.sheet.onClose(); });
+ expect(h.created).not.toHaveBeenCalled();
+ await act(async () => h.sheet.onClosed());
+ expect(h.created).toHaveBeenCalledExactlyOnceWith(hosts[1], ref);
+});
+it('native toolbar keeps single-host creation direct and supports group-only hosts', async () => {
+ await toolbar([hosts[0]]);
+ await act(async () => node.querySelector('button')!.click());
+ expect(h.sheet.deviceId).toBe('mac');
+ await act(async () => { h.sheet.onClose(); h.sheet.onClosed(); });
+ await toolbar([], [hosts[1]]);
+ const group = [...node.querySelectorAll('button')].find(button => button.textContent === 'groupChat.create.title')!;
+ await act(async () => group.click());
+ expect(h.groupSheet.host.deviceId).toBe('pc');
+ await act(async () => { h.groupSheet.onCreated('group'); h.groupSheet.onClose(); });
+ expect(h.groupCreated).not.toHaveBeenCalled();
+ await act(async () => h.groupSheet.onClosed());
+ expect(h.groupCreated).toHaveBeenCalledExactlyOnceWith(hosts[1], 'group');
+});
diff --git a/apps/mobile/src/__tests__/TeammateHomeScreen.test.tsx b/apps/mobile/src/__tests__/TeammateHomeScreen.test.tsx
index 1b7616b4b5..ed78aa154a 100644
--- a/apps/mobile/src/__tests__/TeammateHomeScreen.test.tsx
+++ b/apps/mobile/src/__tests__/TeammateHomeScreen.test.tsx
@@ -5,7 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { HomeMode, LastTeammateIdentity } from '@/session/homeViewPreferenceStore';
import type { HostedRemoteCollectionItem } from '@/device-link/remoteResources';
const h = vi.hoisted(() => ({
- realNavigation: false, stored: null as string | null, tasks: {} as any, dismissTo: vi.fn(), replace: vi.fn(),
+ styles: {}, t: (key: string) => key, realNavigation: false, stored: null as string | null, tasks: {} as any, dismissTo: vi.fn(), replace: vi.fn(),
focused: true, drawer: {} as any, list: {} as any, accounts: {} as any, push: vi.fn(),
auth: { user: { id: 'owner' }, accountGeneration: 1, logout: vi.fn(), beginAddAccount: vi.fn() },
nav: { hydrated: true, lastTeammate: null as LastTeammateIdentity | null, mode: 'teammates' as HomeMode,
@@ -15,21 +15,39 @@ const h = vi.hoisted(() => ({
isOnline: vi.fn(() => true), refresh: vi.fn(), groupTargets: [] as { deviceId: string; deviceName: string }[] },
groups: { loading: false, refreshing: false, error: null as string | null, items: [] as HostedRemoteCollectionItem[], supported: false, isOnline: () => true, refresh: vi.fn() },
groupTargetsSeen: [] as unknown[],
- create: {} as any,
+ create: {} as any, chrome: {} as any, titleArgs: [] as number[], nativeHeader: true, headerHeight: 106, barEdge: 'none',
}));
vi.mock('react-native', async () => {
const { createElement: el } = await import('react');
return { View: ({ children }: any) => el('div', {}, children), ActivityIndicator: () => null,
Pressable: ({ children, onPress }: any) => el('button', { onClick: onPress }, children),
- Keyboard: { dismiss: vi.fn() }, Alert: { alert: vi.fn() }, StyleSheet: { create: (value: unknown) => value } };
+ Keyboard: { dismiss: vi.fn() }, Alert: { alert: vi.fn() }, useWindowDimensions: () => ({ width: 402, height: 874 }), StyleSheet: { create: (value: unknown) => value } };
+});
+vi.mock('@/platform/chrome/homeMenuIcon', () => ({ homeMenuAttentionSize: 6 }));
+vi.mock('@/hooks/useReduceMotion', () => ({ useReduceMotionEnabled: () => true }));
+vi.mock('react-native-reanimated', async () => {
+ const { useRef } = await import('react');
+ const { View } = await import('react-native');
+ return { default: { View }, useSharedValue: (value: number) => useRef({ value }).current,
+ useAnimatedStyle: (factory: () => unknown) => factory(), cancelAnimation: () => {},
+ withSpring: (target: number) => target };
});
vi.mock('expo-router', () => ({ Stack: { Screen: () => null }, useIsFocused: () => h.focused, useNavigation: () => ({ getState: () => ({ routes: [] }) }), useRouter: () => ({ dismissTo: h.dismissTo, replace: h.replace }) }));
+vi.mock('expo-router/react-navigation', () => ({ useHeaderHeight: () => h.headerHeight }));
+vi.mock('@/session/useOptionalHeaderHeight', () => ({ useOptionalHeaderHeight: () => h.headerHeight }));
+vi.mock('@/session/SessionHeaderNativeControls', () => ({ SessionHeaderNativeBlur: () => null }));
+vi.mock('@/platform/AdaptiveWindowContext', () => ({ useAdaptiveWindow: () => ({ width: 402, insets: { left: 0, right: 0 }, barEdge: h.barEdge }) }));
+vi.mock('@/platform/chrome/SimpleStackHeader', () => ({ usesNativeStackHeader: () => h.nativeHeader,
+ simpleScreenSafeAreaEdges: () => h.nativeHeader ? ['left', 'right', 'bottom'] : undefined }));
+vi.mock('@/platform/chrome/HomeStackHeader', () => ({ centeredHomeTitleWidth: (...args: number[]) => { h.titleArgs = args; return 226; }, HomeStackHeader: (props: any) => {
+ h.chrome = props; return createElement('div', { 'data-testid': 'native-home-bar' }, props.title, props.children);
+} }));
vi.mock('react-native-safe-area-context', () => ({ SafeAreaView: 'div' }));
-vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key, i18n: { language: 'en' } }) }));
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: h.t, i18n: { language: 'en' } }) }));
vi.mock('lucide-react-native', () => ({ ChevronDown: () => null, Menu: () => null }));
-vi.mock('@/components/AppText', () => ({ Text: 'span' }));
+vi.mock('@/components/AppText', () => ({ Text: ({ children }: any) => createElement('span', null, children) }));
vi.mock('@/auth/AuthContext', () => ({ useAuth: () => h.auth }));
-vi.mock('@/theme', () => ({ useThemedStyles: () => ({}), useTheme: () => ({ colors: {} }) }));
+vi.mock('@/theme', () => ({ useThemedStyles: () => h.styles, useTheme: () => ({ colors: {} }) }));
vi.mock('@/utils/useGuardedPush', () => ({ useGuardedPush: () => h.push }));
vi.mock('@/device-link/remoteStatus', () => ({ formatRemoteError: String }));
vi.mock('@/session/TeammateCreateButton', () => ({ TeammateCreateButton: (props: any) => { if (props.appearance !== 'cta') h.create = props; return null; } }));
@@ -54,6 +72,7 @@ vi.mock('@/session/remoteSessionStore', () => ({
useRemoteHomeSessions: () => [], useRemoteHomeStatusVersion: () => 0,
}));
import HomeScreen from '../../app/devices/index';
+import { HomeModeProgressContext } from '@/session/HomeModeTransition';
import { Keyboard } from 'react-native';
import { TeammateHomeScreen } from '@/session/TeammateHomeScreen';
import { teammateIdentity } from '@/session/teammateNavigation';
@@ -61,14 +80,14 @@ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
const teammate: HostedRemoteCollectionItem = { key: 'mac:bot', host: { deviceId: 'mac', deviceName: 'Mac' },
item: { ref: { collectionId: 'teammates', kind: 'bot', id: 'writer' }, revision: '1', display: { title: 'Writer' }, links: [] } };
let root: Root | undefined;
-async function render() { root ??= createRoot(document.createElement('div')); await act(async () => root!.render(createElement(TeammateHomeScreen))); }
+async function render(active = true) { root ??= createRoot(document.createElement('div')); await act(async () => root!.render(createElement(TeammateHomeScreen, { active }))); }
let serial = 0;
beforeEach(() => {
h.realNavigation = false; h.stored = null;
h.auth.user = { id: `owner-${++serial}` }; h.auth.accountGeneration = serial;
vi.clearAllMocks(); h.focused = true; h.nav.lastTeammate = teammateIdentity(teammate); h.roster.items = [teammate];
h.nav.mode = 'teammates'; h.nav.chooseMode.mockReset(); h.roster.authoritative = true;
- h.modeMenu = {}; h.nativeMenus = true;
+ h.modeMenu = {}; h.nativeMenus = true; h.nativeHeader = true; h.headerHeight = 106; h.barEdge = 'none'; h.chrome = {};
h.groups.loading = false; h.groups.refreshing = false; h.groups.error = null;
h.roster.loading = false; h.roster.error = null; h.roster.isOnline.mockReturnValue(true);
});
@@ -124,7 +143,8 @@ describe('teammate home entry', () => {
describe('explicit sidebar entry through the home page', () => {
async function renderHome() {
root ??= createRoot(document.createElement('div'));
- await act(async () => root!.render(createElement(HomeScreen)));
+ // The root ResidentHomeListProvider owns this clock in the app; its slide is covered by HomeModePanes.test.
+ await act(async () => root!.render(createElement(HomeModeProgressContext.Provider, { value: { value: 1 } as any }, createElement(HomeScreen))));
}
it.each([1, 2])('keeps a %i-companion roster open across refresh and remount until a row is chosen', async count => {
h.realNavigation = true;
@@ -191,3 +211,62 @@ describe('server groups in the actual teammate home', () => {
await act(async () => h.list.onRefresh()); expect(h.groups.refresh).toHaveBeenCalledOnce();
});
});
+
+describe('shared native home chrome', () => {
+ it('uses the measured bar inset once and opens the existing drawer from the shared menu', async () => {
+ await render();
+ expect(h.list.topInset).toBe(106);
+ expect(h.list.scrollInsetProps).toBeUndefined();
+ expect(h.chrome.menuTestID).toBe('teammates.navigation');
+ // Centered between mirrored margins for the single create item, whatever the task title does.
+ expect(h.titleArgs).toEqual([402, 1]);
+ expect(h.chrome.title.props.style.at(-1).width).toBe(226);
+ await act(async () => h.chrome.onOpenMenu());
+ expect(Keyboard.dismiss).toHaveBeenCalledOnce();
+ expect(h.drawer.open).toBe(true);
+ h.headerHeight = 84; await render();
+ expect(h.list.topInset).toBe(84);
+ });
+ it('does not register a native toolbar while the kept-alive pane is hidden', async () => {
+ await render(false);
+ expect(h.chrome).toEqual({});
+ await render(true);
+ expect(h.chrome.menuTestID).toBe('teammates.navigation');
+ h.chrome = {};
+ await render(false);
+ expect(h.chrome).toEqual({});
+ });
+ it('keeps the Duo top-left exception and the Android fallback', async () => {
+ h.barEdge = 'right'; await render();
+ expect(h.chrome.keepMenuTopLeft).toBe(true);
+ h.nativeHeader = false; h.chrome = {}; await render();
+ expect(h.chrome).toEqual({});
+ expect(h.list.topInset).toBeUndefined();
+ });
+});
+
+it('keeps native title and create toolbar stable through unrelated roster refreshes', async () => {
+ await render();
+ const title = h.chrome.title;
+ const actions = h.chrome.children;
+ h.roster.refreshing = true;
+ await render();
+ expect(h.chrome.title).toBe(title);
+ expect(h.chrome.children).toBe(actions);
+ h.roster.refreshing = false;
+});
+
+it('starts drawer page navigation during exit, while search still waits for the drawer to close', async () => {
+ await render();
+ await act(async () => h.chrome.onOpenMenu());
+ await act(async () => h.drawer.onOpenSettings());
+ expect(h.drawer.open).toBe(false);
+ expect(h.push).toHaveBeenCalledExactlyOnceWith('/settings');
+ await act(async () => h.drawer.onClosed());
+ expect(h.push).toHaveBeenCalledTimes(1);
+ await act(async () => h.chrome.onOpenMenu());
+ await act(async () => h.drawer.onOpenSearch());
+ expect(h.list.autoFocusSearch).toBe(false);
+ await act(async () => h.drawer.onClosed());
+ expect(h.list.autoFocusSearch).toBe(true);
+});
diff --git a/apps/mobile/src/__tests__/TeammateList.test.tsx b/apps/mobile/src/__tests__/TeammateList.test.tsx
index 7487be9561..2d16ff0ef8 100644
--- a/apps/mobile/src/__tests__/TeammateList.test.tsx
+++ b/apps/mobile/src/__tests__/TeammateList.test.tsx
@@ -2,7 +2,7 @@
import { act, createElement as el } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
-const h = vi.hoisted(() => ({ awaiting: new Set<string>() }));
+const h = vi.hoisted(() => ({ awaiting: new Set<string>(), list: {} as any }));
vi.mock('react-native', () => ({
View: ({ children, testID, style }: any) => el('div', { 'data-testid': testID, style: Object.assign({}, ...[style].flat().filter(Boolean)) }, children),
Pressable: ({ children, testID, accessibilityLabel, disabled, onPress, style }: any) => el('button', { 'data-testid': testID, 'aria-label': accessibilityLabel, disabled, onClick: onPress,
@@ -11,7 +11,7 @@ vi.mock('react-native', () => ({
Animated: { View: ({ children, testID }: any) => el('div', { 'data-testid': testID }, children), Value: class { setValue() {} }, timing: () => ({ start() {}, stop() {} }), loop: () => ({ start() {}, stop() {} }), sequence: () => ({}) },
Easing: { inOut: () => undefined, ease: undefined },
StyleSheet: { create: (v: unknown) => v, hairlineWidth: 1 },
- FlatList: ({ ListHeaderComponent, ListEmptyComponent, data, renderItem }: any) => el('div', null, ListHeaderComponent, data.length ? data.map((item: any) => renderItem({ item })) : ListEmptyComponent),
+ FlatList: (props: any) => { h.list = props; const { ListHeaderComponent, ListEmptyComponent, data, renderItem } = props; return el('div', null, ListHeaderComponent, data.length ? data.map((item: any, index: number) => renderItem({ item, index })) : ListEmptyComponent); },
}));
vi.mock('@/device-link/DeviceLinkContext', () => ({ useDeviceLink: () => ({ invoke: async () => ({ blocks: [] }) }) }));
vi.mock('@/session/remoteSessionStore', () => ({ remoteSessionStore: {
@@ -167,3 +167,20 @@ it('mixes group chats into the list by latest activity', async () => {
await act(async () => (node.querySelector('[data-testid="group.g1"]') as HTMLButtonElement).click());
expect(onGroup).toHaveBeenCalledWith(group);
});
+
+it('reserves the native home bar once for content, scroll indicator and refresh; other routes keep automatic insets', async () => {
+ const props = { items: [item], error: null, isOnline: () => true, loading: false, refreshing: false, onRefresh: vi.fn(), onSelect: vi.fn() };
+ await act(async () => root.render(el(TeammateList, { ...props, topInset: 106, notice: el('span', null, 'Preference could not be saved') })));
+ expect(Object.assign({}, ...h.list.contentContainerStyle.filter(Boolean)).paddingTop).toBe(106);
+ expect(h.list.contentInsetAdjustmentBehavior).toBe('never');
+ expect(h.list.automaticallyAdjustsScrollIndicatorInsets).toBe(false);
+ expect(h.list.scrollIndicatorInsets).toEqual({ top: 106 });
+ expect(h.list.refreshControl.props.progressViewOffset).toBe(106);
+ expect(node.textContent).toContain('Preference could not be saved');
+ await act(async () => root.render(el(TeammateList, { ...props,
+ scrollInsetProps: { contentInsetAdjustmentBehavior: 'automatic', automaticallyAdjustsScrollIndicatorInsets: true },
+ })));
+ expect(h.list.contentInsetAdjustmentBehavior).toBe('automatic');
+ expect(h.list.automaticallyAdjustsScrollIndicatorInsets).toBe(true);
+ expect(h.list.scrollIndicatorInsets).toBeUndefined();
+});
diff --git a/apps/mobile/src/__tests__/edgeBlurMask.test.ts b/apps/mobile/src/__tests__/edgeBlurMask.test.ts
index 8cb71b598e..4b44593a0f 100644
--- a/apps/mobile/src/__tests__/edgeBlurMask.test.ts
+++ b/apps/mobile/src/__tests__/edgeBlurMask.test.ts
@@ -1,7 +1,7 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
-import { EDGE_BLUR_FADE_INSIDE, EDGE_BLUR_FADE_OUTSIDE, edgeBlurMask } from '@/session/edgeBlurMask';
+import { EDGE_BLUR_FADE_INSIDE, EDGE_BLUR_FADE_OUTSIDE, HEADER_BLUR_FADE_OUTSIDE, edgeBlurMask, headerBlurLayers } from '@/session/edgeBlurMask';
const readTextLf = (path: string): string =>
String(readFileSync(resolve(process.cwd(), path), 'utf8')).replace(/\r\n/g, '\n');
@@ -38,6 +38,30 @@ describe('edge blur mask', () => {
expect(alphas[7] - alphas[8]).toBeLessThan(alphas[4] - alphas[5]);
});
+ it('can keep the whole chrome solid and feather only past its edge', () => {
+ const mask = edgeBlurMask(111, 'top', 0);
+ expect(mask.height).toBe(127);
+ expect(mask.startPoint.y * mask.height).toBeCloseTo(111);
+ expect(mask.endPoint.y).toBe(1);
+ });
+
+ it('thins the header blur progressively: three layers end at a third, two thirds and the full fade', () => {
+ expect(HEADER_BLUR_FADE_OUTSIDE).toBe(24);
+ const layers = headerBlurLayers(100);
+ expect(layers).toHaveLength(3);
+ for (const layer of layers) {
+ expect(layer.height).toBe(124);
+ // Every layer is solid over the chrome until 24pt above its edge.
+ expect(layer.startPoint.y * layer.height).toBeCloseTo(100 - 24);
+ }
+ expect(layers.map(layer => layer.endPoint.y * layer.height)).toEqual([76 + 16, 76 + 32, 124].map(value => expect.closeTo(value)));
+ });
+
+ it('keeps a chat header fully solid and starts every header layer at its edge', () => {
+ for (const layer of headerBlurLayers(111, 0)) expect(layer.startPoint.y * layer.height).toBeCloseTo(111);
+ expect(headerBlurLayers(111, 0).at(-1)!.endPoint.y).toBe(1);
+ });
+
it('keeps short chrome partly solid by capping the inside feather at half its height', () => {
const mask = edgeBlurMask(20, 'top');
expect(mask.startPoint.y * mask.height).toBeCloseTo(10);
diff --git a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts b/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
index 0c77cf4e67..18b945811c 100644
--- a/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
+++ b/apps/mobile/src/__tests__/homeDesktopFirst.test.ts
@@ -809,14 +809,16 @@ describe('mobile home desktop-first surface', () => {
describe('home menu native header ownership', () => {
it('hosts the Duo top-left menu inside the native bar instead of under its touch surface', () => {
const home = readSource('src/session/HomeSurface.tsx');
- const header = readSource('src/platform/chrome/HomeNativeStackHeader.tsx');
+ const header = readSource('src/platform/chrome/HomeStackHeader.tsx');
+ expect(readSource('src/platform/chrome/HomeNativeStackHeader.tsx')).toContain('<HomeStackHeader');
expect(home).toContain("nativeHomeHeader && homeGeometry.barEdge !== 'none'");
expect(home).toContain('keepMenuTopLeft={keepMenuTopLeft}');
expect(home).not.toContain('{keepMenuTopLeft ? (');
const leftToolbar = header.split('<Stack.Toolbar placement="left">')[1].split('</Stack.Toolbar>')[0];
expect(leftToolbar).toContain('<Stack.Toolbar.View hidesSharedBackground>');
expect(leftToolbar).toContain('onPress={onOpenMenu}');
- expect(leftToolbar).toContain('testID="home.chromeMenu"');
+ expect(leftToolbar).toContain('testID={menuTestID}');
+ expect(readSource('src/platform/chrome/HomeNativeStackHeader.tsx')).toContain('menuTestID="home.chromeMenu"');
// Ordinary system toolbar actions keep their native adaptation.
expect(leftToolbar).toContain('<Stack.Toolbar.Button');
});
diff --git a/apps/mobile/src/__tests__/recentMessageHistories.test.tsx b/apps/mobile/src/__tests__/recentMessageHistories.test.tsx
index 8b21e12ee4..314294ac1d 100644
--- a/apps/mobile/src/__tests__/recentMessageHistories.test.tsx
+++ b/apps/mobile/src/__tests__/recentMessageHistories.test.tsx
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
-import { act, createContext, useEffect, useImperativeHandle, useState, type ReactNode, type Ref } from 'react';
+import { act, createContext, useEffect, useImperativeHandle, useRef, useState, type ReactNode, type Ref } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { setMobileAuthOwner } from '@/auth/authOwnerGeneration';
@@ -29,6 +29,9 @@ vi.mock('@/session/remoteSessionStore', () => ({
<div data-store-gate={String(enabled)}>{children}</div>,
}));
vi.mock('react-native-reanimated', () => ({
+ useSharedValue: (value: number) => useRef({ value }).current,
+ useAnimatedStyle: (factory: () => unknown) => factory(),
+ cancelAnimation: () => {}, withSpring: (target: number) => target,
default: {
View: ({ children, pointerEvents, style }: { children: ReactNode; pointerEvents?: string; style?: unknown }) =>
<div data-resident-host="true" data-input={pointerEvents} data-layout={JSON.stringify(style)}>{children}</div>,
diff --git a/apps/mobile/src/__tests__/residentHomeList.test.tsx b/apps/mobile/src/__tests__/residentHomeList.test.tsx
index 68c8240496..7d0d371c37 100644
--- a/apps/mobile/src/__tests__/residentHomeList.test.tsx
+++ b/apps/mobile/src/__tests__/residentHomeList.test.tsx
@@ -2,15 +2,16 @@
import { act, memo, useEffect, useState } from 'react';
import { createRoot } from 'react-dom/client';
import { afterEach, expect, it, vi } from 'vitest';
+Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
import { homeRowPropsEqual } from '../session/homeRowPropsEqual';
import { ResidentHomeList, ResidentHomeListProvider } from '../session/ResidentHomeList';
const state = vi.hoisted(() => ({
- mode: 'tasks', segments: ['devices'], width: 1000, anchorWidth: 1000, mounts: 0, unmounts: 0,
+ hydrated: true, reduceMotion: true, progress: null as any, slide: null as any, mode: 'tasks', segments: ['devices'], width: 1000, anchorWidth: 1000, mounts: 0, unmounts: 0,
}));
-vi.mock('../session/useHomeMode', () => ({ useHomeMode: () => ({ mode: state.mode }) }));
+vi.mock('../session/useHomeMode', () => ({ useHomeMode: () => ({ mode: state.mode, hydrated: state.hydrated }) }));
vi.mock('expo-router', () => ({ useSegments: () => state.segments }));
-vi.mock('@/hooks/useReduceMotion', () => ({ useReduceMotionEnabled: () => true }));
+vi.mock('@/hooks/useReduceMotion', () => ({ useReduceMotionEnabled: () => state.reduceMotion }));
vi.mock('@/platform/AdaptiveWindowContext', () => ({ useAdaptiveWindow: () => ({
width: state.width, height: 800, regularWidth: true, regularHeight: true,
barEdge: 'right', insets: { top: 0, bottom: 0, left: 0, right: 80 },
@@ -32,13 +33,18 @@ vi.mock('react-native', async () => {
}),
};
});
-vi.mock('react-native-reanimated', () => ({
- default: { View: ({ children, pointerEvents }: any) => <div data-host data-pointer={pointerEvents}>{children}</div> },
-}));
+vi.mock('react-native-reanimated', async () => {
+ const { useRef } = await import('react');
+ return { default: { View: ({ children, pointerEvents }: any) => <div data-host data-pointer={pointerEvents}>{children}</div> },
+ useSharedValue: (value: number) => { const ref = useRef({ value }); state.progress = ref.current; return ref.current; },
+ useAnimatedStyle: (factory: () => any) => { state.slide = factory; return factory(); },
+ cancelAnimation: () => {}, withSpring: (target: number) => target,
+ };
+});
const roots: ReturnType<typeof createRoot>[] = [];
afterEach(() => {
act(() => roots.splice(0).forEach(root => root.unmount()));
- state.mode = 'tasks'; state.segments = ['devices']; state.width = 1000; state.anchorWidth = 1000;
+ state.hydrated = true; state.reduceMotion = true; state.mode = 'tasks'; state.segments = ['devices']; state.width = 1000; state.anchorWidth = 1000;
state.mounts = 0; state.unmounts = 0;
});
const ListProbe = memo(function ListProbe({ onSelect }: { onSelect(): void }) {
@@ -108,3 +114,14 @@ it.each([{ homeSegments: [] }, { homeSegments: ['index'] }, { homeSegments: ['de
expect(host.querySelector('[data-select]')?.textContent).toBe('240');
expect(state.mounts).toBe(1); expect(state.unmounts).toBe(0);
});
+
+it('slides the wide resident list out with its home pane without remounting or intercepting teammate touches', () => {
+ state.reduceMotion = false;
+ const host = document.createElement('div'); const root = createRoot(host); roots.push(root);
+ const render = () => act(() => root.render(<Scene detail={false} homeSelect={() => {}} />));
+ render(); state.mode = 'teammates'; render(); state.progress.value = 0.5;
+ expect(state.slide()).toEqual({ opacity: 1, transform: [{ translateX: -500 }] });
+ expect(host.querySelector('[data-host]')?.getAttribute('data-pointer')).toBe('none');
+ state.progress.value = 1; expect(state.slide().opacity).toBe(0);
+ expect(state.mounts).toBe(1); expect(state.unmounts).toBe(0);
+});
diff --git a/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts b/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts
index 4326f8e236..5bb15e078c 100644
--- a/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts
+++ b/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts
@@ -95,7 +95,7 @@ describe('mobile session header desktop-first surface', () => {
expect(source).toContain('<View onLayout={handleKeyboardAreaLayout} pointerEvents="none" style={StyleSheet.absoluteFill} />');
expect(source).toContain('testID="session.composerFrost"');
expect(source).toContain('<View ref={topOverlayRef} onLayout={handleTopOverlayLayout} pointerEvents="box-none" style={styles.sessionChrome} testID="session.chrome">');
- expect(source).toContain('<View style={[styles.sessionChromeContent, { paddingTop: horizontalSystemHeader ? nativeHeaderHeight : insets.top + (paneLayout.persistent ? spacing.lg : 0) }, companionChat && { backgroundColor: colors.surface }]}>');
+ expect(source).toContain('<View style={[styles.sessionChromeContent, { paddingTop: horizontalSystemHeader ? nativeHeaderHeight : insets.top + (paneLayout.persistent ? spacing.lg : 0) }, companionChat && Platform.OS !== \'ios\' && { backgroundColor: colors.surface }]}>');
// 临时任务列表抽屉在树内,盖不住 iOS 系统栏:抽屉存续期间收起系统栏,内容区沿用打开前的顶栏高度。
expect(source).toContain(']), sessionListDrawerOverlayMounted);');
expect(source).toContain('systemBarHidden={sessionListDrawerOverlayMounted}');
diff --git a/apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx b/apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx
index 3f2f2cfc41..5f6a77ebc6 100644
--- a/apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx
+++ b/apps/mobile/src/platform/chrome/HomeNativeStackHeader.tsx
@@ -1,9 +1,10 @@
-import { memo, useState, type ComponentProps, type ReactNode } from "react";
+import { memo, useState } from "react";
import { Stack } from "expo-router";
-import { HomeHeaderGlassButton } from "@/session/HomeHeaderGlassButton";
+import { centeredHomeTitleWidth, HomeStackHeader } from "./HomeStackHeader";
+import { nativeToolbarMenuItems } from "./nativeToolbarMenuItems";
import { QuietSyncIndicator } from '@/components/QuietSyncIndicator';
import { useDelayedConnectionNotice } from '@/components/ConnectionNoticeOverlay';
-import { ChevronDown, Menu } from "lucide-react-native";
+import { ChevronDown } from "lucide-react-native";
import { Pressable, StyleSheet, View } from "react-native";
import { useSafeAreaFrame, useSafeAreaInsets } from "react-native-safe-area-context";
import { Text } from "@/components/AppText";
@@ -26,7 +27,7 @@ import { lineHeight, navigationChrome, spacing } from "@/theme/tokens";
/**
* 首页 iOS 顶栏走系统 UINavigationBar。
- * 透明导航栏;设备标题使用与任务标题相同的轻磨砂胶囊。Android 不渲染。
+ * 透明导航栏;标题保留任务范围的长名称避让规则。Android 不渲染。
*
* memo:系统顶栏(react-native-screens)每次选项变化都会整组重建 bar button item,展开中的
* 菜单随之关闭。调用方须传稳定的 props(菜单内容无实质变化时保持同一引用),避免后台同步
@@ -82,11 +83,9 @@ export const HomeNativeStackHeader = memo(function HomeNativeStackHeader({
// remote-desktop action, a name that fits the mirrored width stays centered;
// a longer one takes the gap, right-aligned, and grows into the spare room
// beside the menu before it ellipsizes. Mirrored margins add UIKit's title
- // clearance, otherwise iOS 26 shifts the title toward the leading edge. The
- // cap keeps wide windows, whose bar margins differ, from clipping both ends.
+ // clearance, otherwise iOS 26 shifts the title toward the leading edge.
const trailingItems = showRemoteGuide ? 0 : onOpenRemoteDesktop ? 2 : 1;
- const mirroredWidth = Math.max(navigationChrome.target, Math.min(360,
- barWidth - (navigationChrome.target * Math.max(1, trailingItems) + spacing.lg * 2 + spacing.md) * 2));
+ const mirroredWidth = centeredHomeTitleWidth(barWidth, trailingItems);
const gapWidth = Math.max(navigationChrome.target, Math.min(360,
barWidth - navigationChrome.target * (1 + trailingItems) - spacing.lg * 4 - spacing.xs));
const [naturalWidth, setNaturalWidth] = useState<number | null>(null);
@@ -156,74 +155,22 @@ export const HomeNativeStackHeader = memo(function HomeNativeStackHeader({
);
return (
- <>
- <Stack.Screen
- options={{
- headerBackVisible: false,
- headerShadowVisible: false,
- headerShown: true,
- headerStyle: { backgroundColor: "transparent" },
- headerTintColor: colors.textPrimary,
- headerTransparent: true,
- headerTitle: () => (
- <View style={[styles.titleFrame, { width: titleWidth }]}>
- {titleMeasure}
- {titleNode}
- </View>
- ),
- }}
- />
- <Stack.Header
- style={{
- backgroundColor: "transparent",
- color: colors.textPrimary,
- shadowColor: "transparent",
- }}
- />
- <Stack.Toolbar placement="left">
- {keepMenuTopLeft ? (
- // This home-only custom item stays at the top left on Duo. Hosting it
- // in the native bar keeps its hit target above the transparent header.
- <Stack.Toolbar.View hidesSharedBackground>
- <HomeHeaderGlassButton accessibilityLabel={menuA11y} onPress={onOpenMenu} testID="home.chromeMenu">
- <Menu color={colors.textPrimary} size={iconSize.action} strokeWidth={iconStroke.regular} />
- </HomeHeaderGlassButton>
- </Stack.Toolbar.View>
- ) : (
- <Stack.Toolbar.Button icon="line.3.horizontal" accessibilityLabel={menuA11y} onPress={onOpenMenu} />
- )}
- </Stack.Toolbar>
+ <HomeStackHeader menuA11y={menuA11y} menuTestID="home.chromeMenu" onOpenMenu={onOpenMenu}
+ keepMenuTopLeft={keepMenuTopLeft}
+ title={<View style={[styles.titleFrame, { width: titleWidth }]}>{titleMeasure}{titleNode}</View>}>
{showRemoteGuide ? null : (
<Stack.Toolbar placement="right">
{onOpenRemoteDesktop ? <Stack.Toolbar.Button icon={require("../../../assets/navigation/monitor.png")} iconRenderingMode="template"
accessibilityLabel={remoteDesktopA11y} onPress={onOpenRemoteDesktop} /> : null}
<Stack.Toolbar.Menu icon="ellipsis" accessibilityLabel={displayA11y}>
- {displayMenuItems(displayActions, onDisplayAction)}
+ {nativeToolbarMenuItems(displayActions, onDisplayAction)}
</Stack.Toolbar.Menu>
</Stack.Toolbar>
)}
- </>
+ </HomeStackHeader>
);
});
-function displayMenuItems(actions: readonly NativePullDownAction[], onAction: (id: string) => void): ReactNode {
- return actions.map(action => action.subactions?.length ? (
- <Stack.Toolbar.Menu key={action.id} title={action.title} inline={action.displayInline}
- subtitle={action.subtitle}
- icon={action.image as ComponentProps<typeof Stack.Toolbar.Menu>['icon']}
- disabled={action.disabled} destructive={action.destructive}>
- {displayMenuItems(action.subactions, onAction)}
- </Stack.Toolbar.Menu>
- ) : (
- <Stack.Toolbar.MenuAction key={action.id} disabled={action.disabled}
- destructive={action.destructive} isOn={action.state === 'on'} subtitle={action.subtitle}
- icon={action.image as ComponentProps<typeof Stack.Toolbar.MenuAction>['icon']}
- unstable_keepPresented={action.keepPresented} onPress={() => onAction(action.id)}>
- {action.title}
- </Stack.Toolbar.MenuAction>
- ));
-}
-
const makeStyles = (colors: ThemeColors) =>
StyleSheet.create({
pressed: { opacity: 0.72 },
diff --git a/apps/mobile/src/platform/chrome/HomeStackHeader.tsx b/apps/mobile/src/platform/chrome/HomeStackHeader.tsx
new file mode 100644
index 0000000000..364cec2ee3
--- /dev/null
+++ b/apps/mobile/src/platform/chrome/HomeStackHeader.tsx
@@ -0,0 +1,71 @@
+import { memo, type ReactNode } from 'react';
+import { Image, StyleSheet, View } from 'react-native';
+import { Stack } from 'expo-router';
+import { HomeHeaderGlassButton } from '@/session/HomeHeaderGlassButton';
+import { useTheme } from '@/theme';
+import { navigationChrome, spacing } from '@/theme/tokens';
+import { homeMenuArtworkSize, homeMenuAttentionIcon, homeMenuIcon } from './homeMenuIcon';
+
+/**
+ * Widest title view UIKit keeps centered on the bar: mirrored side margins sized for the
+ * larger side's items plus UIKit's title clearance. The cap keeps wide windows, whose
+ * bar margins differ, from clipping both ends.
+ */
+export function centeredHomeTitleWidth(barWidth: number, trailingItems: number): number {
+ return Math.max(navigationChrome.target, Math.min(360,
+ barWidth - (navigationChrome.target * Math.max(1, trailingItems) + spacing.lg * 2 + spacing.md) * 2));
+}
+
+/**
+ * Shared iOS home chrome. Callers own title content and business actions, not bar geometry.
+ * The bar's blur is drawn once by HomeModePanes, outside the sliding panes.
+ */
+export const HomeStackHeader = memo(function HomeStackHeader({
+ title,
+ menuA11y,
+ menuTestID,
+ onOpenMenu,
+ keepMenuTopLeft = false,
+ attention = false,
+ children,
+}: {
+ title: ReactNode;
+ menuA11y: string;
+ menuTestID: string;
+ onOpenMenu(): void;
+ keepMenuTopLeft?: boolean;
+ attention?: boolean;
+ /** Route-owned native toolbars; keep items inside their Stack.Toolbar container. */
+ children?: ReactNode;
+}) {
+ const { colors } = useTheme();
+ const artwork = attention ? homeMenuAttentionIcon : homeMenuIcon;
+ return <>
+ <Stack.Screen options={{
+ headerBackVisible: false, headerShadowVisible: false, headerShown: true,
+ headerStyle: { backgroundColor: 'transparent' }, headerTintColor: colors.textPrimary,
+ headerTransparent: true, headerTitleAlign: 'center', headerTitle: () => title,
+ }} />
+ <Stack.Header style={{ backgroundColor: 'transparent', color: colors.textPrimary, shadowColor: 'transparent' }} />
+ <Stack.Toolbar placement="left">
+ {keepMenuTopLeft ? (
+ // Duo keeps the menu at top left, inside the native bar's hit surface.
+ <Stack.Toolbar.View hidesSharedBackground>
+ <View style={styles.menu}>
+ <HomeHeaderGlassButton accessibilityLabel={menuA11y} onPress={onOpenMenu} testID={menuTestID} artworkSize={homeMenuArtworkSize}>
+ <Image source={artwork} tintColor={colors.textPrimary} style={styles.artwork} />
+ </HomeHeaderGlassButton>
+ </View>
+ </Stack.Toolbar.View>
+ ) : (
+ <Stack.Toolbar.Button icon={artwork} iconRenderingMode="template" accessibilityLabel={menuA11y} onPress={onOpenMenu} />
+ )}
+ </Stack.Toolbar>
+ {children}
+ </>;
+});
+
+const styles = StyleSheet.create({
+ artwork: { width: homeMenuArtworkSize, height: homeMenuArtworkSize },
+ menu: { width: navigationChrome.target, height: navigationChrome.target },
+});
diff --git a/apps/mobile/src/platform/chrome/NativeChromeBackButton.tsx b/apps/mobile/src/platform/chrome/NativeChromeBackButton.tsx
new file mode 100644
index 0000000000..38e7547d8c
--- /dev/null
+++ b/apps/mobile/src/platform/chrome/NativeChromeBackButton.tsx
@@ -0,0 +1,11 @@
+import { ChevronLeft } from "lucide-react-native";
+import { HomeHeaderGlassButton } from "@/session/HomeHeaderGlassButton";
+import { iconSize, iconStroke, useTheme } from "@/theme";
+
+/** Non-iOS fallback for the system back chevron, at the chrome glyph size. */
+export function NativeChromeBackButton({ label, onPress, testID }: { label: string; onPress(): void; testID: string }) {
+ const { colors } = useTheme();
+ return <HomeHeaderGlassButton testID={testID} accessibilityLabel={label} onPress={onPress}>
+ <ChevronLeft size={iconSize.action} strokeWidth={iconStroke.regular} color={colors.textPrimary} />
+ </HomeHeaderGlassButton>;
+}
diff --git a/apps/mobile/src/platform/chrome/homeMenuIcon.ts b/apps/mobile/src/platform/chrome/homeMenuIcon.ts
new file mode 100644
index 0000000000..604f30b2cc
--- /dev/null
+++ b/apps/mobile/src/platform/chrome/homeMenuIcon.ts
@@ -0,0 +1,6 @@
+/** Same narrow 20pt glyph centered in a 26pt transparent canvas in both states. */
+export const homeMenuArtworkSize = 26;
+/** Visible dot diameter, not a text-badge container. */
+export const homeMenuAttentionSize = 6;
+export const homeMenuIcon = require('../../../assets/navigation/menu.png');
+export const homeMenuAttentionIcon = require('../../../assets/navigation/menu-attention.png');
diff --git a/apps/mobile/src/platform/chrome/nativeToolbarMenuItems.tsx b/apps/mobile/src/platform/chrome/nativeToolbarMenuItems.tsx
new file mode 100644
index 0000000000..371d7b10ac
--- /dev/null
+++ b/apps/mobile/src/platform/chrome/nativeToolbarMenuItems.tsx
@@ -0,0 +1,23 @@
+import type { ComponentProps, ReactNode } from 'react';
+import { Stack } from 'expo-router';
+import type { NativePullDownAction } from './NativePullDownMenu';
+
+// Return actual toolbar elements: Expo Router inspects their types before rendering.
+
+export function nativeToolbarMenuItems(actions: readonly NativePullDownAction[], onAction: (id: string) => void): ReactNode {
+ return actions.map(action => action.subactions?.length ? (
+ <Stack.Toolbar.Menu key={action.id} title={action.title} inline={action.displayInline}
+ subtitle={action.subtitle}
+ icon={action.image as ComponentProps<typeof Stack.Toolbar.Menu>['icon']}
+ disabled={action.disabled} destructive={action.destructive}>
+ {nativeToolbarMenuItems(action.subactions, onAction)}
+ </Stack.Toolbar.Menu>
+ ) : (
+ <Stack.Toolbar.MenuAction key={action.id} disabled={action.disabled}
+ destructive={action.destructive} isOn={action.state === 'on'} subtitle={action.subtitle}
+ icon={action.image as ComponentProps<typeof Stack.Toolbar.MenuAction>['icon']}
+ unstable_keepPresented={action.keepPresented} onPress={() => onAction(action.id)}>
+ {action.title}
+ </Stack.Toolbar.MenuAction>
+ ));
+}
diff --git a/apps/mobile/src/session/BotGroupChatScreen.tsx b/apps/mobile/src/session/BotGroupChatScreen.tsx
index eb0603b8bd..82dfc460d5 100644
--- a/apps/mobile/src/session/BotGroupChatScreen.tsx
+++ b/apps/mobile/src/session/BotGroupChatScreen.tsx
@@ -20,7 +20,7 @@ import {
type NativeSyntheticEvent,
} from 'react-native';
import { Stack, useRouter } from 'expo-router';
-import { SafeAreaView } from 'react-native-safe-area-context';
+import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { useTranslation } from 'react-i18next';
import { resolveRemoteText } from '@cindy/device-link';
import {
@@ -53,7 +53,7 @@ import { readRemoteCollectionCache } from '@/device-link/remoteResourceAvailabil
import type { RemoteResourceHostTarget } from '@/device-link/remoteResources';
import { useTheme, useThemedStyles, type ThemeColors } from '@/theme';
import { useUserBubbleAppearance } from '@/theme/userBubblePreference';
-import { fontWeight, lineHeight, radius, spacing, typeScale } from '@/theme/tokens';
+import { fontWeight, lineHeight, navigationChrome, radius, spacing, typeScale } from '@/theme/tokens';
import { goBackGuarded } from '@/utils/backGuard';
import {
BOT_GROUP_MESSAGE_AVATAR_SIZE,
@@ -61,7 +61,8 @@ import {
BotGroupDuoAvatar,
useBotGroupIdentities,
} from './BotGroupAvatars';
-import { ChatIdentityHeader } from './ChatIdentityHeader';
+import { CHAT_HEADER_BLUR_FADE_INSIDE, ChatIdentityHeader } from './ChatIdentityHeader';
+import { SessionHeaderNativeBlur } from './SessionHeaderNativeControls';
import { CompanionEntering } from './CompanionEntering';
import { BotGroupComposer, type BotGroupSendInput } from './BotGroupComposer';
import { BotGroupMessageAttachments } from './BotGroupMessageAttachments';
@@ -118,6 +119,10 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId }: { deviceId
const [planPending, setPlanPending] = useState<PlanPending | null>(null);
const planPendingRef = useRef(false);
const scrollRef = useRef<ScrollView>(null);
+ // 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 [headerHeight, setHeaderHeight] = useState(0);
const stickToBottom = useRef(true);
const group = chat.state.kind === 'ready' ? chat.state.group : null;
const focused = useIsFocused();
@@ -262,6 +267,8 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId }: { deviceId
onOpenSettings={() => setSettings(true)}
settingsLabel={t('groupChat.settings.open')} />;
+ const offlineNote = group && !chat.online
+ ? <Text accessibilityRole="alert" style={styles.offline} testID="botGroup.offlineNote">{t(offlineKey)}</Text> : null;
let body;
if (chat.state.kind === 'loading' && !chat.online) {
// Nothing to show until the computer is reachable again; the screen re-reads on reconnect.
@@ -297,8 +304,9 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId }: { deviceId
Platform.OS === 'ios' ? 'ios' : Platform.OS === 'android' ? 'android' : 'web',
)}
>
- {!chat.online ? <Text accessibilityRole="alert" style={styles.offline} testID="botGroup.offlineNote">{t(offlineKey)}</Text> : null}
- <ScrollView ref={scrollRef} style={styles.flex} contentContainerStyle={styles.timeline} keyboardShouldPersistTaps="handled"
+ {floatingHeader ? null : offlineNote}
+ <ScrollView ref={scrollRef} style={styles.flex} contentContainerStyle={[styles.timeline, floatingHeader && { paddingTop: headerHeight + spacing.md }]}
+ scrollIndicatorInsets={floatingHeader ? { top: headerHeight } : undefined} keyboardShouldPersistTaps="handled"
keyboardDismissMode="interactive"
maintainVisibleContentPosition={chat.server ? { minIndexForVisible: group.hasMoreBefore ? 1 : 0 } : undefined}
onScroll={onScroll} scrollEventThrottle={64}
@@ -325,10 +333,19 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId }: { deviceId
</KeyboardAvoidingView>;
}
- return <SafeAreaView style={styles.screen} edges={['top', 'left', 'right', 'bottom']} testID="botGroup.screen">
+ return <SafeAreaView style={styles.screen} edges={floatingHeader ? ['left', 'right', 'bottom'] : ['top', 'left', 'right', 'bottom']} testID="botGroup.screen">
<Stack.Screen options={{ headerShown: false }} />
- {header}
- {body}
+ {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)}>
+ {header}
+ {offlineNote}
+ </View>
+ </> : <>
+ {header}
+ {body}
+ </>}
{group ? <BotGroupSettingsSheet readOnly={chat.server} visible={settings} group={group} host={host} identityFor={identityFor} online={chat.online}
act={chat.act} onClose={() => setSettings(false)}
onRefresh={chat.reload}
@@ -523,6 +540,7 @@ function BotGroupTimelineItem({
const makeStyles = (colors: ThemeColors) => StyleSheet.create({
screen: { flex: 1, backgroundColor: colors.surface },
flex: { flex: 1 },
+ floatingHeader: { position: 'absolute', top: 0, left: 0, right: 0, zIndex: 10 },
center: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: spacing.xl },
emptyActions: { flexDirection: 'row', justifyContent: 'center', gap: spacing.sm, marginTop: spacing.lg },
timeline: { flexGrow: 1, justifyContent: 'flex-end', gap: spacing.lg, paddingHorizontal: spacing.lg, paddingVertical: spacing.md },
diff --git a/apps/mobile/src/session/ChatIdentityHeader.tsx b/apps/mobile/src/session/ChatIdentityHeader.tsx
index 789fc4cf23..453f3216b3 100644
--- a/apps/mobile/src/session/ChatIdentityHeader.tsx
+++ b/apps/mobile/src/session/ChatIdentityHeader.tsx
@@ -1,13 +1,21 @@
import type { ReactNode } from 'react';
import { Keyboard, Pressable, StyleSheet, View } from 'react-native';
-import { ChevronLeft, Settings2 } from 'lucide-react-native';
+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 { HomeHeaderGlassButton } from './HomeHeaderGlassButton';
/** Identity mark size in chat headers: a 32pt avatar (1:1) or a 32pt two-member group mark. */
export const CHAT_HEADER_MARK_SIZE = 32;
+/** 18pt trailing glyphs at ~1.65pt, level with the 20pt back chevron rather than thinner beside it. */
+export const CHAT_HEADER_GLYPH_STROKE = iconStroke.medium;
+/**
+ * The identity's subtitle runs to the header's lower edge, so the header blur stays solid across
+ * the whole header and feathers only below it.
+ */
+export const CHAT_HEADER_BLUR_FADE_INSIDE = 0;
/**
* 私聊与群聊共用的顶栏(C1 / G1):返回 + 身份区(32 标记、标题 16/22 600、副标题 12/18 三级色)+
@@ -36,9 +44,8 @@ export function ChatIdentityHeader({
const styles = useThemedStyles(makeStyles);
const open = () => { if (controlsReady) { Keyboard.dismiss(); onOpenSettings(); } };
return <View style={styles.header} testID={`${testIDPrefix}.header`}>
- <HomeHeaderGlassButton testID={`${testIDPrefix}.back`} accessibilityLabel={t('shared.back')} onPress={() => { Keyboard.dismiss(); onBack(); }}>
- <ChevronLeft size={iconSize.action} strokeWidth={iconStroke.regular} color={colors.textPrimary} />
- </HomeHeaderGlassButton>
+ {/* 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="button"
accessibilityLabel={identityLabel} accessibilityHint={identityHint} accessibilityState={{ disabled: !controlsReady }}
disabled={!controlsReady} onPress={open} testID={`${testIDPrefix}.identity`}>
@@ -50,7 +57,7 @@ export function ChatIdentityHeader({
</Pressable>
{accessory}
<HomeHeaderGlassButton testID={settingsTestID ?? `${testIDPrefix}.settings`} disabled={!controlsReady} accessibilityLabel={settingsLabel} onPress={open}>
- <Settings2 size={iconSize.lg} strokeWidth={iconStroke.regular} color={colors.textPrimary} />
+ <Settings2 size={iconSize.lg} strokeWidth={CHAT_HEADER_GLYPH_STROKE} color={colors.textPrimary} />
</HomeHeaderGlassButton>
</View>;
}
diff --git a/apps/mobile/src/session/CompanionBackButton.ios.tsx b/apps/mobile/src/session/CompanionBackButton.ios.tsx
deleted file mode 100644
index bcfc226f75..0000000000
--- a/apps/mobile/src/session/CompanionBackButton.ios.tsx
+++ /dev/null
@@ -1,6 +0,0 @@
-import { NativeChromeBackButton } from '@/platform/chrome/NativeChromeBackButton.ios';
-
-/** Same native back control as the task header (system chevron, chrome size). */
-export function CompanionBackButton({ label, onPress }: { label: string; onPress(): void }) {
- return <NativeChromeBackButton testID="companion.back" label={label} onPress={onPress} />;
-}
diff --git a/apps/mobile/src/session/CompanionBackButton.tsx b/apps/mobile/src/session/CompanionBackButton.tsx
deleted file mode 100644
index 4600a6d30d..0000000000
--- a/apps/mobile/src/session/CompanionBackButton.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { ChevronLeft } from 'lucide-react-native';
-import { iconSize, iconStroke, useTheme } from '@/theme';
-import { HomeHeaderGlassButton } from './HomeHeaderGlassButton';
-
-/** Non-iOS fallback matching ScreenBackButton's icon metrics. */
-export function CompanionBackButton({ label, onPress }: { label: string; onPress(): void }) {
- const { colors } = useTheme();
- return <HomeHeaderGlassButton testID="companion.back" accessibilityLabel={label} onPress={onPress}>
- <ChevronLeft size={iconSize.action} strokeWidth={iconStroke.regular} color={colors.textPrimary} />
- </HomeHeaderGlassButton>;
-}
diff --git a/apps/mobile/src/session/CompanionHeader.tsx b/apps/mobile/src/session/CompanionHeader.tsx
index ba2a755652..21e4c89975 100644
--- a/apps/mobile/src/session/CompanionHeader.tsx
+++ b/apps/mobile/src/session/CompanionHeader.tsx
@@ -7,8 +7,8 @@ import { useTranslation } from 'react-i18next';
import { resolveRemoteText, type RemoteResource } from '@cindy/device-link';
import { useAuth } from '@/auth/AuthContext';
import { RemoteCompanionAvatar } from '@/components/RemoteCompanionAvatar';
-import { radius, spacing, iconSize, iconStroke, useTheme, useThemedStyles, type ThemeColors } from '@/theme';
-import { CHAT_HEADER_MARK_SIZE, ChatIdentityHeader, ChatIdentitySubtitle } from './ChatIdentityHeader';
+import { radius, spacing, iconSize, useTheme, useThemedStyles, type ThemeColors } from '@/theme';
+import { CHAT_HEADER_GLYPH_STROKE, CHAT_HEADER_MARK_SIZE, ChatIdentityHeader, ChatIdentitySubtitle } from './ChatIdentityHeader';
import { CompanionPresenceRing } from './CompanionPresenceRing';
import { CompanionProfileSheet } from './CompanionProfileSheet';
import { useTeammateNavigation } from './useTeammateNavigation';
@@ -61,7 +61,7 @@ function CompanionHeaderContent({ resource, deviceId, deviceName, online, contro
controlsReady={controlsReady}
onBack={onBack}
onOpenSettings={() => { setInitialPage('home'); setProfile(true); }}
- accessory={resource.links?.some(link=>link.target.kind==='resource'&&link.target.ref.id==='todos:'+resource.ref.id)?<HomeHeaderGlassButton testID="companion.todos.open" disabled={!controlsReady} accessibilityLabel={t('devices.teammateTodo.title')} onPress={()=>setTodos(true)}><ListTodo size={iconSize.lg} strokeWidth={iconStroke.regular} color={colors.textPrimary}/></HomeHeaderGlassButton>:undefined}
+ accessory={resource.links?.some(link=>link.target.kind==='resource'&&link.target.ref.id==='todos:'+resource.ref.id)?<HomeHeaderGlassButton testID="companion.todos.open" disabled={!controlsReady} accessibilityLabel={t('devices.teammateTodo.title')} onPress={()=>setTodos(true)}><ListTodo size={iconSize.lg} strokeWidth={CHAT_HEADER_GLYPH_STROKE} color={colors.textPrimary}/></HomeHeaderGlassButton>:undefined}
settingsLabel={t('devices.companionProfile.settingsTitle')} />
<CompanionTodos visible={todos} onClose={()=>setTodos(false)} botId={resource.ref.id} deviceId={deviceId} deviceName={deviceName} online={online}/>
<CompanionProfileSheet initialPage={initialPage} visible={profile} onClose={() => setProfile(false)} onClosed={() => { const action = pending.current; pending.current = null; action?.(); }}
diff --git a/apps/mobile/src/session/HomeModePanes.tsx b/apps/mobile/src/session/HomeModePanes.tsx
index b54baeccc8..e952467c75 100644
--- a/apps/mobile/src/session/HomeModePanes.tsx
+++ b/apps/mobile/src/session/HomeModePanes.tsx
@@ -1,17 +1,42 @@
import { useState, type ReactNode } from 'react';
-import { View } from 'react-native';
+import { StyleSheet, View } from 'react-native';
+import Animated, { useAnimatedStyle, type SharedValue } from 'react-native-reanimated';
+import { useAdaptiveWindow } from '@/platform/AdaptiveWindowContext';
+import { SessionHeaderNativeBlur } from '@/session/SessionHeaderNativeControls';
+import { useOptionalHeaderHeight } from '@/session/useOptionalHeaderHeight';
+import { homeModeIndex, useHomeModeSlide } from './HomeModeTransition';
import type { HomeMode } from './homeViewPreferenceStore';
-/** Keep the task mirror mounted for navigation counts; keep visited panes alive: local searches, expansion and list positions belong to each mode. */
+/** Keep visited panes alive: search, expansion and scroll belong to each tab. */
export function HomeModePanes({ mode, tasks, teammates }: { mode: HomeMode; tasks: ReactNode; teammates: ReactNode }) {
+ const progress = useHomeModeSlide();
+ // Same distance as the wide resident list, so both layers stay adjacent mid-slide.
+ const { width } = useAdaptiveWindow();
+ const headerHeight = useOptionalHeaderHeight();
const [visited, setVisited] = useState({ tasks: true, teammates: mode === 'teammates' });
if (!visited[mode]) setVisited({ ...visited, [mode]: true });
- return <View style={{ flex: 1 }}>
+ return <View style={styles.viewport}>
{(['tasks', 'teammates'] as const).map(pane => visited[pane] || mode === pane ?
- <View key={pane} testID={`home.pane.${pane}`} style={{ flex: 1, display: mode === pane ? 'flex' : 'none' }}
- pointerEvents={mode === pane ? 'auto' : 'none'} accessibilityElementsHidden={mode !== pane}
- importantForAccessibility={mode === pane ? 'auto' : 'no-hide-descendants'}>
+ <HomePane key={pane} pane={pane} active={mode === pane} width={width} progress={progress}>
{pane === 'tasks' ? tasks : teammates}
- </View> : null)}
+ </HomePane> : null)}
+ {/* The native bar does not slide, so neither does its blur. */}
+ <SessionHeaderNativeBlur height={headerHeight} />
</View>;
}
+
+function HomePane({ pane, active, width, progress, children }: {
+ pane: HomeMode; active: boolean; width: number; progress: SharedValue<number>; children: ReactNode;
+}) {
+ const index = homeModeIndex(pane);
+ const slide = useAnimatedStyle(() => ({ transform: [{ translateX: (index - progress.value) * width }] }));
+ return <Animated.View testID={'home.pane.' + pane} style={[StyleSheet.absoluteFill, slide]}
+ pointerEvents={active ? 'auto' : 'none'} accessibilityElementsHidden={!active}
+ importantForAccessibility={active ? 'auto' : 'no-hide-descendants'}>
+ {children}
+ </Animated.View>;
+}
+
+const styles = StyleSheet.create({
+ viewport: { flex: 1, overflow: 'hidden' },
+});
diff --git a/apps/mobile/src/session/HomeModeTransition.ts b/apps/mobile/src/session/HomeModeTransition.ts
new file mode 100644
index 0000000000..890dabbdd9
--- /dev/null
+++ b/apps/mobile/src/session/HomeModeTransition.ts
@@ -0,0 +1,36 @@
+import { createContext, useContext, useEffect, useLayoutEffect, useRef } from 'react';
+import { cancelAnimation, useSharedValue, withSpring, type SharedValue } from 'react-native-reanimated';
+import { useReduceMotionEnabled } from '@/hooks/useReduceMotion';
+import type { HomeMode } from './homeViewPreferenceStore';
+
+/**
+ * Critically damped (~0.35s response), clamped: no visible bounce. A spring rather than
+ * a duration tier, so a reversal mid-slide starts moving at once and a short remaining
+ * distance settles quickly instead of replaying a full ease-in-out (DESIGN.md §14.4).
+ */
+export const HOME_MODE_SLIDE_SPRING = { mass: 1, stiffness: 320, damping: 36, overshootClamping: true } as const;
+
+/** One UI-thread clock, owned by ResidentHomeListProvider, for the panes and the wide resident list. */
+export const HomeModeProgressContext = createContext<SharedValue<number> | null>(null);
+export const homeModeIndex = (mode: HomeMode) => mode === 'tasks' ? 0 : 1;
+
+export function useHomeModeProgress(mode: HomeMode, animate: boolean, ready: boolean): SharedValue<number> {
+ const progress = useSharedValue(homeModeIndex(mode));
+ const reduceMotion = useReduceMotionEnabled();
+ const wasReady = useRef(ready);
+ useLayoutEffect(() => {
+ const canAnimate = animate && ready && wasReady.current && reduceMotion === false;
+ wasReady.current = ready;
+ const target = homeModeIndex(mode);
+ // Assign over a running slide (no cancel first) so the spring keeps its velocity.
+ if (progress.value !== target) progress.value = canAnimate ? withSpring(target, HOME_MODE_SLIDE_SPRING) : target;
+ }, [animate, mode, progress, ready, reduceMotion]);
+ useEffect(() => () => cancelAnimation(progress), [progress]);
+ return progress;
+}
+
+export function useHomeModeSlide(): SharedValue<number> {
+ const progress = useContext(HomeModeProgressContext);
+ if (!progress) throw new Error('useHomeModeSlide requires ResidentHomeListProvider');
+ return progress;
+}
diff --git a/apps/mobile/src/session/HomeSurface.tsx b/apps/mobile/src/session/HomeSurface.tsx
index fa19293bb3..21ee9cbd33 100644
--- a/apps/mobile/src/session/HomeSurface.tsx
+++ b/apps/mobile/src/session/HomeSurface.tsx
@@ -9,7 +9,6 @@ import { useRetainedHomeState, getHomeViewSession } from './homeViewSession';
import { rememberRecentTask } from './recentTasks';
import { homeListStyles, SESSION_ROW_LONG_PRESS_MS, SessionStatusMark, SessionStatusPulse } from '@/session/HomeListVisuals';
import { useOptionalHeaderHeight } from '@/session/useOptionalHeaderHeight';
-import { SessionHeaderNativeBlur } from "@/session/SessionHeaderNativeControls";
import { rememberComposerEntry } from './composerMorph';
import type { ComposerMorphOrigin } from './composerGeometry';
import { RemoteTaskSuggestions } from '@/session/RemoteTaskSuggestions';
@@ -3114,7 +3113,6 @@ function HomeScreenContent({ active = true, onModeChange, width, newSessionInSys
style={[styles.safeArea, { paddingLeft: embedded ? 0 : edgePadding.paddingLeft, paddingRight: embedded ? 0 : edgePadding.paddingRight }]}
testID="devices.screen"
>
- {nativeHomeHeader ? <SessionHeaderNativeBlur height={nativeHeaderHeight} /> : null}
{nativeHomeHeader && active ? (
<HomeNativeStackHeader
keepMenuTopLeft={keepMenuTopLeft}
diff --git a/apps/mobile/src/session/ResidentHomeList.tsx b/apps/mobile/src/session/ResidentHomeList.tsx
index a3d86c2ea3..4a7aeb3e01 100644
--- a/apps/mobile/src/session/ResidentHomeList.tsx
+++ b/apps/mobile/src/session/ResidentHomeList.tsx
@@ -1,7 +1,8 @@
import { useHomeMode } from './useHomeMode';
import { createContext, useCallback, useContext, useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react';
import { StyleSheet, View } from 'react-native';
-import Animated from 'react-native-reanimated';
+import Animated, { useAnimatedStyle } from 'react-native-reanimated';
+import { HomeModeProgressContext, useHomeModeProgress } from './HomeModeTransition';
import { useSegments } from 'expo-router';
import { useAdaptiveWindow } from '@/platform/AdaptiveWindowContext';
import { useReduceMotionEnabled } from '@/hooks/useReduceMotion';
@@ -41,10 +42,17 @@ export function ResidentHomeListProvider({ children }: { children: ReactNode })
const geometry = useAdaptiveWindow();
const enabled = sessionPaneLayout(geometry).persistent;
const segments = useSegments() as string[];
- const { mode } = useHomeMode();
- // The retained task list must not overlay the teammate home pane.
- const visible = enabled && ((mode === 'tasks' && (segments.length === 0 || segments[0] === 'index' || (segments[0] === 'devices' && (segments.length === 1 || segments[1] === 'index'))))
+ const { mode, hydrated } = useHomeMode();
+ const homeRoute = segments.length === 0 || segments[0] === 'index'
+ || (segments[0] === 'devices' && (segments.length === 1 || segments[1] === 'index'));
+ const progress = useHomeModeProgress(mode, homeRoute, hydrated);
+ // Keep the outgoing resident list drawn during the slide, but never interactive over the new tab.
+ const visible = enabled && ((mode === 'tasks' && homeRoute)
|| (segments[0] === 'sessions' && segments[1] === '[sessionId]'));
+ const slide = useAnimatedStyle(() => ({
+ opacity: homeRoute ? (progress.value < 1 ? 1 : 0) : (visible ? 1 : 0),
+ transform: [{ translateX: homeRoute ? -progress.value * geometry.width : 0 }],
+ }));
const host = useRef<View>(null);
const mounted = useRef(false);
const [entry, setEntry] = useState<Entry | null>(null);
@@ -55,21 +63,20 @@ export function ResidentHomeListProvider({ children }: { children: ReactNode })
mounted.current = enabled && !!entry;
if (!enabled) setEntry(null);
}, [enabled, entry]);
- return <Context.Provider value={context}>
+ return <HomeModeProgressContext.Provider value={progress}><Context.Provider value={context}>
<View ref={host} collapsable={false} style={styles.root}>
{children}
{entry ? <Animated.View pointerEvents={visible ? 'box-none' : 'none'}
accessibilityElementsHidden={!visible}
importantForAccessibility={visible ? 'auto' : 'no-hide-descendants'}
style={[styles.host, entry.frame, {
- opacity: visible ? 1 : 0,
transitionProperty: ['left', 'top', 'width', 'height'],
transitionDuration: reduceMotion === false ? motionDuration.fast : 0,
- }]}>
+ }, slide]}>
<RemoteSessionStoreSubscriptionGate enabled={visible}>{entry.children}</RemoteSessionStoreSubscriptionGate>
</Animated.View> : null}
</View>
- </Context.Provider>;
+ </Context.Provider></HomeModeProgressContext.Provider>;
}
/** A route supplies a measuring slot, not another native list. Its header stays
diff --git a/apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx b/apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx
index 6d70587420..691df199a0 100644
--- a/apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx
+++ b/apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx
@@ -11,7 +11,7 @@ import {
VStack,
} from "@expo/ui/swift-ui";
import { Folder, Monitor, Pin, type LucideIcon } from "lucide-react-native";
-import { Pressable, View } from "react-native";
+import { Pressable, StyleSheet, View } from "react-native";
import { Text } from "@/components/AppText";
import { QuietSyncIndicator } from "@/components/QuietSyncIndicator";
import { TaskTagDots } from './TaskTags';
@@ -39,7 +39,7 @@ import {
useTheme,
} from "@/theme";
import { BlurBackdrop, FLOATING_CHROME_BLUR_INTENSITY } from "./BlurBackdrop";
-import { edgeBlurMask } from "./edgeBlurMask";
+import { edgeBlurMask, headerBlurLayers, HEADER_BLUR_LAYER_INTENSITY, type EdgeBlurMask } from "./edgeBlurMask";
import type {
SessionHeaderNativeActionsProps,
SessionHeaderNativeBackProps,
@@ -49,11 +49,13 @@ import type {
/**
* A stationary, feathered backdrop: scrolling content passes beneath it.
* `height` is the chrome area; the blur is solid over most of it and eases out
- * across its content-side edge (see edgeBlurMask).
+ * across its content-side edge. Headers use the progressive layers of
+ * headerBlurLayers; the composer keeps one layer (see edgeBlurMask).
*/
-export function SessionHeaderNativeBlur({ height: chromeHeight, edge = 'top', inset = 0 }: { height: number; edge?: 'top' | 'bottom'; inset?: number }) {
- const { mode } = useTheme();
- const mask = edgeBlurMask(chromeHeight, edge);
+export function SessionHeaderNativeBlur({ height: chromeHeight, edge = 'top', inset = 0, fadeInside }: { height: number; edge?: 'top' | 'bottom'; inset?: number; fadeInside?: number }) {
+ const layers = edge === 'top'
+ ? headerBlurLayers(chromeHeight, fadeInside).map((mask) => ({ mask, intensity: HEADER_BLUR_LAYER_INTENSITY }))
+ : [{ mask: edgeBlurMask(chromeHeight, edge, fadeInside), intensity: FLOATING_CHROME_BLUR_INTENSITY }];
return (
<View
pointerEvents="none"
@@ -63,35 +65,42 @@ export function SessionHeaderNativeBlur({ height: chromeHeight, edge = 'top', in
...(edge === 'top' ? { top: inset } : { bottom: inset }),
left: 0,
right: 0,
- height: mask.height,
+ height: layers[0]!.mask.height,
zIndex: 9,
}}
>
- <Host colorScheme={mode} ignoreSafeArea="all" style={{ flex: 1 }}>
- <Mask modifiers={[frame({ maxWidth: Infinity, maxHeight: Infinity })]}>
- <RNHostView>
- <View style={{ flex: 1 }}>
- <BlurBackdrop intensity={FLOATING_CHROME_BLUR_INTENSITY} overlayColor="transparent" />
- </View>
- </RNHostView>
- <Mask.Content>
- <Rectangle
- modifiers={[
- foregroundStyle({
- type: "linearGradient",
- colors: mask.colors,
- startPoint: mask.startPoint,
- endPoint: mask.endPoint,
- }),
- ]}
- />
- </Mask.Content>
- </Mask>
- </Host>
+ {layers.map(({ mask, intensity }, index) => <MaskedBlur key={index} mask={mask} intensity={intensity} />)}
</View>
);
}
+function MaskedBlur({ mask, intensity }: { mask: EdgeBlurMask; intensity: number }) {
+ const { mode } = useTheme();
+ return (
+ <Host colorScheme={mode} ignoreSafeArea="all" style={StyleSheet.absoluteFill}>
+ <Mask modifiers={[frame({ maxWidth: Infinity, maxHeight: Infinity })]}>
+ <RNHostView>
+ <View style={{ flex: 1 }}>
+ <BlurBackdrop intensity={intensity} overlayColor="transparent" />
+ </View>
+ </RNHostView>
+ <Mask.Content>
+ <Rectangle
+ modifiers={[
+ foregroundStyle({
+ type: "linearGradient",
+ colors: mask.colors,
+ startPoint: mask.startPoint,
+ endPoint: mask.endPoint,
+ }),
+ ]}
+ />
+ </Mask.Content>
+ </Mask>
+ </Host>
+ );
+}
+
export function SessionHeaderNativeTitle({ title,
tags,
onTagsPress,
diff --git a/apps/mobile/src/session/SessionHeaderNativeControls.tsx b/apps/mobile/src/session/SessionHeaderNativeControls.tsx
index a384a0fd36..026a2124f5 100644
--- a/apps/mobile/src/session/SessionHeaderNativeControls.tsx
+++ b/apps/mobile/src/session/SessionHeaderNativeControls.tsx
@@ -21,7 +21,7 @@ export function SessionHeaderNativeTitle(_props: SessionHeaderNativeTitleProps)
return null;
}
-export function SessionHeaderNativeBlur(_props: { height: number; edge?: 'top' | 'bottom'; inset?: number }) {
+export function SessionHeaderNativeBlur(_props: { height: number; edge?: 'top' | 'bottom'; inset?: number; fadeInside?: number }) {
return null;
}
diff --git a/apps/mobile/src/session/TeammateCreateButton.tsx b/apps/mobile/src/session/TeammateCreateButton.tsx
index e9ac6e65ed..0e3e4c719f 100644
--- a/apps/mobile/src/session/TeammateCreateButton.tsx
+++ b/apps/mobile/src/session/TeammateCreateButton.tsx
@@ -1,5 +1,7 @@
import { useEffect, useRef, useState } from 'react';
import { Alert } from 'react-native';
+import { Stack } from 'expo-router';
+import { nativeToolbarMenuItems } from '@/platform/chrome/nativeToolbarMenuItems';
import { Plus } from 'lucide-react-native';
import { useTranslation } from 'react-i18next';
import type { RemoteResourceRef } from '@cindy/device-link';
@@ -26,7 +28,7 @@ type Choice = { kind: CreateKind; host: RemoteResourceHostTarget };
export function TeammateCreateButton({ targets, groupTargets = [], preferredDeviceId, onCreated, onGroupCreated, appearance = 'glass' }: {
targets: readonly RemoteResourceHostTarget[];
/** `cta`: the empty list's primary button; it only creates a teammate. */
- appearance?: 'glass' | 'cta';
+ appearance?: 'glass' | 'cta' | 'toolbar';
/** Online computers that support group chats; empty keeps the single-purpose button. */
groupTargets?: readonly RemoteResourceHostTarget[];
preferredDeviceId?: string;
@@ -101,8 +103,15 @@ function CreateButton({ targets, groupTargets = [], preferredDeviceId, onCreated
return (choice.kind === 'bot' ? ordered : orderedGroups).length > 1 ? `${verb} · ${choice.host.deviceName}` : verb;
};
const groupOpen = open?.kind === 'group' ? open : null;
+ const menu = needsMenu && menuActions.length > 0;
+ let trigger = button;
+ if (appearance === 'toolbar') trigger = <Stack.Toolbar placement="right">
+ {menu ? <Stack.Toolbar.Menu icon="plus" accessibilityLabel={label}>{nativeToolbarMenuItems(menuActions, onMenu)}</Stack.Toolbar.Menu>
+ : <Stack.Toolbar.Button icon="plus" accessibilityLabel={label} onPress={press} />}
+ </Stack.Toolbar>;
+ else if (!cta && menu) trigger = <NativePullDownMenu actions={menuActions} onAction={onMenu} testID="teammates.createMenu">{button}</NativePullDownMenu>;
return <>
- {!cta && needsMenu && menuActions.length ? <NativePullDownMenu actions={menuActions} onAction={onMenu} testID="teammates.createMenu">{button}</NativePullDownMenu> : button}
+ {trigger}
<CompanionSheet visible={choosing} title={label} testID="teammates.createChooser" onClose={() => { pendingChoice.current = null; setChoosing(false); }}
onClosed={() => { const choice = pendingChoice.current; pendingChoice.current = null; if (choice) start(choice.kind, choice.host.deviceId); }}>
{/* Same choice as the header's native menu: one plain row per choice, not full-width buttons. */}
diff --git a/apps/mobile/src/session/TeammateHomeScreen.tsx b/apps/mobile/src/session/TeammateHomeScreen.tsx
index 744a85fdd2..a2336b37e3 100644
--- a/apps/mobile/src/session/TeammateHomeScreen.tsx
+++ b/apps/mobile/src/session/TeammateHomeScreen.tsx
@@ -1,12 +1,19 @@
-import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';
+import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore, type ComponentProps } from 'react';
import { Alert, Keyboard, Pressable, StyleSheet, View } from 'react-native';
import { Stack, useIsFocused, useRouter } from 'expo-router';
+import { useHeaderHeight } from 'expo-router/react-navigation';
+import { homeMenuAttentionSize } from '@/platform/chrome/homeMenuIcon';
+import { centeredHomeTitleWidth, HomeStackHeader } from '@/platform/chrome/HomeStackHeader';
+import { simpleScreenSafeAreaEdges, usesNativeStackHeader } from '@/platform/chrome/SimpleStackHeader';
+import { useAdaptiveWindow } from '@/platform/AdaptiveWindowContext';
import { ChevronDown, Menu } from 'lucide-react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useTranslation } from 'react-i18next';
import { useAuth } from '@/auth/AuthContext';
import { Text } from '@/components/AppText';
import { formatRemoteError } from '@/device-link/remoteStatus';
+import { useStableValue } from '@/utils/useStableValue';
+import type { RemoteResourceHostTarget } from '@/device-link/remoteResources';
import { useGuardedPush } from '@/utils/useGuardedPush';
import { useTheme, useThemedStyles, type ThemeColors } from '@/theme';
import { fontWeight, iconSize, iconStroke, lineHeight, navigationChrome, radius, spacing, typeScale } from '@/theme/tokens';
@@ -52,15 +59,31 @@ export function TeammateHomeScreen({ active = true }: { active?: boolean }) {
useCallback((listener) => accounts || drawer ? remoteSessionStore.subscribe(listener) : () => {}, [accounts, drawer]),
useCallback(() => (accounts || drawer) && remoteSessionStore.getSessions().some((session) => remoteSessionStore.isSessionRunning(session.id)), [accounts, drawer]),
);
- const groupCreateTargets = roster.groupTargets.filter(groups.isOnline);
+ const nativeHeader = usesNativeStackHeader();
+ const headerHeight = useHeaderHeight();
+ const geometry = useAdaptiveWindow();
+ // Teammates stays centered even when the task title needs to grow toward a toolbar.
+ const titleWidth = centeredHomeTitleWidth(geometry.width - geometry.insets.left - geometry.insets.right, 1);
+ const openMenu = useCallback(() => { Keyboard.dismiss(); setDrawer(true); }, []);
+ const menuA11y = [t('devices.companions.openNavigation'),
+ counts.tasks > 0 ? t('devices.companions.taskAttentionCount', { count: counts.tasks }) : ''].filter(Boolean).join(', ');
+ // Roster refreshes allocate new arrays; unchanged menu contents must not close an open native menu.
+ const createTargets = useStableValue(roster.createTargets, sameHosts);
+ const groupCreateTargets = useStableValue(roster.groupTargets.filter(groups.isOnline), sameHosts);
const nativeMenus = usesNativePullDownMenu();
- const modeActions = [
+ const modeActions = useMemo(() => [
{ id: 'tasks', title: t('devices.companions.tasks'), state: 'off' as const },
{ id: 'teammates', title: t('devices.companions.title'), state: 'on' as const },
- ];
- const selectMode = (id: string) => {
+ ], [t]);
+ const selectMode = useCallback((id: string) => {
if (id === 'tasks') void navigation.chooseMode('tasks');
- };
+ }, [navigation.chooseMode]);
+ const onCreated = useCallback<ComponentProps<typeof TeammateCreateButton>['onCreated']>((host, ref) => {
+ void navigation.openCreatedTeammate(host, ref);
+ }, [navigation.openCreatedTeammate]);
+ const onGroupCreated = useCallback<NonNullable<ComponentProps<typeof TeammateCreateButton>['onGroupCreated']>>((host, groupId) => {
+ push(botGroupRoute(host, groupId));
+ }, [push]);
const afterDrawer = (action: () => void) => { pending.current = action; setDrawer(false); };
const openDrawerPage = (href: Parameters<typeof push>[0]) => {
pending.current = null;
@@ -72,43 +95,56 @@ export function TeammateHomeScreen({ active = true }: { active?: boolean }) {
mounted.current = true;
return () => { mounted.current = false; pending.current = null; };
}, []);
- return <SafeAreaView style={styles.screen} testID="teammates.home">
- {active ? <Stack.Screen options={{ headerShown: false }} /> : null}
- <View style={styles.header}>
- <View style={styles.slot}>
- <View style={styles.navButton}>
- <HomeHeaderGlassButton accessibilityLabel={[t('devices.companions.openNavigation'),
- counts.tasks > 0 ? t('devices.companions.taskAttentionCount', { count: counts.tasks }) : ''].filter(Boolean).join(', ')}
- testID="teammates.navigation" onPress={() => { Keyboard.dismiss(); setDrawer(true); }}>
- <Menu color={colors.textPrimary} size={iconSize.action} strokeWidth={iconStroke.regular} />
- </HomeHeaderGlassButton>
- {/* The other side (tasks) needs a look; the drawer shows how many. Neutral, not a status color. */}
- {counts.tasks > 0 ? <View pointerEvents="none" style={styles.navDot} testID="teammates.navigation.dot" /> : null}
- </View>
- </View>
+ const titleControl = useMemo(() => (
<NativePullDownMenu actions={modeActions} onAction={selectMode} style={styles.titleMenu}>
<Pressable
accessibilityLabel={t('devices.companions.title')}
accessibilityRole="button"
- onPress={nativeMenus ? undefined : () => { Keyboard.dismiss(); setDrawer(true); }}
+ onPress={nativeMenus ? undefined : openMenu}
style={({ pressed }) => [styles.titleTrigger, pressed && styles.pressed]}
testID="teammates.modeMenu"
>
<View style={styles.titleCluster}>
- <Text style={styles.title}>{t('devices.companions.title')}</Text>
+ <Text numberOfLines={1} style={styles.title}>{t('devices.companions.title')}</Text>
<ChevronDown color={colors.textSecondary} size={iconSize.xs} strokeWidth={iconStroke.medium} />
</View>
</Pressable>
</NativePullDownMenu>
- <View style={[styles.slot, styles.slotEnd]}>
- {roster.createTargets.length > 0 || groupCreateTargets.length > 0 ? <TeammateCreateButton targets={roster.createTargets}
+ ), [modeActions, selectMode, styles, t, nativeMenus, openMenu, colors.textSecondary]);
+ const nativeTitle = useMemo(() => <View style={[styles.nativeTitle, { width: titleWidth }]}>{titleControl}</View>, [styles, titleControl, titleWidth]);
+ const createControl = useMemo(() => createTargets.length > 0 || groupCreateTargets.length > 0 ? <TeammateCreateButton appearance={nativeHeader ? 'toolbar' : 'glass'} targets={createTargets}
groupTargets={groupCreateTargets} preferredDeviceId={navigation.lastTeammate?.deviceId}
- onCreated={(host, ref) => { void navigation.openCreatedTeammate(host, ref); }}
- onGroupCreated={(host, groupId) => { push(botGroupRoute(host, groupId)); }} /> : null}
+ onCreated={onCreated} onGroupCreated={onGroupCreated} /> : null,
+ [createTargets, groupCreateTargets, nativeHeader, navigation.lastTeammate?.deviceId, onCreated, onGroupCreated]);
+ return <SafeAreaView edges={simpleScreenSafeAreaEdges()} style={styles.screen} testID="teammates.home">
+ {/* iOS: only the visible home pane registers the shared native chrome. */}
+ {nativeHeader && active ? <HomeStackHeader title={nativeTitle}
+ menuA11y={menuA11y} menuTestID="teammates.navigation" onOpenMenu={openMenu}
+ attention={counts.tasks > 0} keepMenuTopLeft={geometry.barEdge !== 'none'}>
+ {createControl}
+ </HomeStackHeader> : null}
+ {nativeHeader ? null : <>
+ {active ? <Stack.Screen options={{ headerShown: false }} /> : null}
+ <View style={styles.header}>
+ <View style={styles.slot}>
+ <View style={styles.navButton}>
+ <HomeHeaderGlassButton accessibilityLabel={menuA11y}
+ testID="teammates.navigation" onPress={openMenu}>
+ <Menu color={colors.textPrimary} size={iconSize.action} strokeWidth={iconStroke.regular} />
+ </HomeHeaderGlassButton>
+ {/* The other side (tasks) needs a look; the drawer shows how many. Neutral, not a status color. */}
+ {counts.tasks > 0 ? <View pointerEvents="none" style={styles.navDot} testID="teammates.navigation.dot" /> : null}
+ </View>
+ </View>
+ {titleControl}
+ <View style={[styles.slot, styles.slotEnd]}>
+ {createControl}
</View>
</View>
- {navigation.saveFailed ? <Text accessibilityRole="alert" style={styles.notice}>{t('devices.companions.preferenceSaveFailed')}</Text> : null}
- <TeammateList key={searchEpoch} {...roster} autoFocusSearch={searchEpoch > 0}
+ </>}
+ <TeammateList key={searchEpoch} {...roster}
+ topInset={nativeHeader ? headerHeight : undefined}
+ notice={navigation.saveFailed ? <Text accessibilityRole="alert" style={styles.notice}>{t('devices.companions.preferenceSaveFailed')}</Text> : null} autoFocusSearch={searchEpoch > 0}
loading={roster.items.length + groups.items.length === 0 && (roster.loading || groups.loading)}
refreshing={roster.refreshing || groups.refreshing}
error={groups.error ?? roster.error}
@@ -146,17 +182,22 @@ export function TeammateHomeScreen({ active = true }: { active?: boolean }) {
}
const makeStyles = (colors: ThemeColors) => StyleSheet.create({
screen: { backgroundColor: colors.surface, flex: 1 },
- // Same chrome as the task home header: 48 tall, 16 side gutter, 92-wide slots keep the title centered.
+ // Android fallback: iOS geometry and menu belong to HomeStackHeader.
header: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: spacing.lg, paddingBottom: spacing.md, minHeight: 48 },
slot: { width: navigationChrome.target * 2 + spacing.xs, flexDirection: 'row' },
slotEnd: { justifyContent: 'flex-end' },
navButton: { width: navigationChrome.target, height: navigationChrome.target },
- navDot: { position: 'absolute', top: 6, right: 6, width: 8, height: 8, borderRadius: radius.pill, backgroundColor: colors.textPrimary,
- borderWidth: 2, borderColor: colors.surface },
+ navDot: { position: 'absolute', top: spacing.sm, right: spacing.sm, width: homeMenuAttentionSize, height: homeMenuAttentionSize, borderRadius: radius.pill, backgroundColor: colors.textPrimary },
+ nativeTitle: { height: navigationChrome.target },
titleMenu: { flex: 1 },
titleTrigger: { alignItems: 'center', flex: 1, justifyContent: 'center', minHeight: navigationChrome.target, minWidth: navigationChrome.target },
- titleCluster: { alignItems: 'center', flexDirection: 'row', gap: spacing.xs },
- title: { color: colors.textPrimary, fontSize: typeScale.title, lineHeight: lineHeight.title, fontWeight: fontWeight.semibold },
+ titleCluster: { maxWidth: '100%', alignItems: 'center', flexDirection: 'row', gap: spacing.xs },
+ title: { flexShrink: 1, color: colors.textPrimary, fontSize: typeScale.title, lineHeight: lineHeight.title, fontWeight: fontWeight.semibold },
pressed: { opacity: 0.72 },
notice: { color: colors.textSecondary, fontSize: typeScale.footnote, lineHeight: lineHeight.caption, padding: spacing.lg },
});
+
+function sameHosts(a: readonly RemoteResourceHostTarget[], b: readonly RemoteResourceHostTarget[]): boolean {
+ return a.length === b.length && a.every((host, index) =>
+ host.deviceId === b[index].deviceId && host.deviceName === b[index].deviceName);
+}
diff --git a/apps/mobile/src/session/TeammateList.tsx b/apps/mobile/src/session/TeammateList.tsx
index 97c24cdfc6..07fcb8bf23 100644
--- a/apps/mobile/src/session/TeammateList.tsx
+++ b/apps/mobile/src/session/TeammateList.tsx
@@ -60,6 +60,9 @@ export interface TeammateListProps {
groups?: TeammateListGroups;
/** Home only: the create entry shown under an empty list. */
emptyAction?: ReactElement | null;
+ /** Explicit inset for the overlaid home bar; other routes keep automatic scroll insets. */
+ topInset?: number;
+ notice?: ReactElement | null;
/** 独立整页、铺到透明系统顶栏下时,由列表自己让出上下安全区。 */
scrollInsetProps?: Pick<ScrollViewProps, 'automaticallyAdjustsScrollIndicatorInsets' | 'contentInsetAdjustmentBehavior'>;
}
@@ -83,7 +86,7 @@ function useAwaitingSessions(items: readonly HostedRemoteCollectionItem[]): Read
/** Identity list shared by home (with group chats) and the collection route. No host headings. */
export function TeammateList({ items, loading, refreshing, error, isOnline, connectionState, onRefresh, onSelect,
- embedded = false, autoFocusSearch = false, onInteract, groups, emptyAction, scrollInsetProps }: TeammateListProps) {
+ embedded = false, autoFocusSearch = false, onInteract, groups, emptyAction, scrollInsetProps, topInset, notice }: TeammateListProps) {
const { t, i18n } = useTranslation();
const { user } = useAuth();
const { colors } = useTheme();
@@ -203,11 +206,14 @@ export function TeammateList({ items, loading, refreshing, error, isOnline, conn
return <BotGroupListRow key={`group:${entry.row.key}`} row={entry.row} online={groups.isOnline(entry.row.host)} last={last}
onPress={() => groups.onSelect(entry.row)} />;
};
- if (embedded) return <View testID="teammates.list">{header}{entries.length ? entries.map(renderEntry) : empty}</View>;
- return <FlatList {...scrollInsetProps} style={styles.list} contentContainerStyle={styles.content} data={entries} keyExtractor={(entry) => `${entry.kind}:${entry.row.key}`}
+ if (embedded) return <View testID="teammates.list">{notice}{header}{entries.length ? entries.map(renderEntry) : empty}</View>;
+ return <FlatList {...scrollInsetProps} style={styles.list} contentContainerStyle={[styles.content, topInset !== undefined && { paddingTop: topInset }]}
+ contentInsetAdjustmentBehavior={topInset !== undefined ? 'never' : scrollInsetProps?.contentInsetAdjustmentBehavior}
+ automaticallyAdjustsScrollIndicatorInsets={topInset !== undefined ? false : scrollInsetProps?.automaticallyAdjustsScrollIndicatorInsets}
+ scrollIndicatorInsets={topInset !== undefined ? { top: topInset } : undefined} data={entries} keyExtractor={(entry) => `${entry.kind}:${entry.row.key}`}
keyboardShouldPersistTaps="handled" keyboardDismissMode="on-drag" onScrollBeginDrag={onInteract} testID="teammates.list"
- ListHeaderComponent={header} ListEmptyComponent={empty} renderItem={({ item, index }) => renderEntry(item, index)}
- refreshControl={<RefreshControl refreshing={refreshing} onRefresh={onRefresh} tintColor={colors.textSecondary} />} />;
+ ListHeaderComponent={<>{notice}{header}</>} ListEmptyComponent={empty} renderItem={({ item, index }) => renderEntry(item, index)}
+ refreshControl={<RefreshControl progressViewOffset={topInset} refreshing={refreshing} onRefresh={onRefresh} tintColor={colors.textSecondary} />} />;
}
/**
diff --git a/apps/mobile/src/session/edgeBlurMask.ts b/apps/mobile/src/session/edgeBlurMask.ts
index 9b088c7a6c..f078b97c89 100644
--- a/apps/mobile/src/session/edgeBlurMask.ts
+++ b/apps/mobile/src/session/edgeBlurMask.ts
@@ -30,10 +30,14 @@ export interface EdgeBlurMask {
endPoint: { x: number; y: number };
}
-/** Mask geometry for a backdrop whose chrome sits at `edge` and whose feather faces the content. */
-export function edgeBlurMask(chromeHeight: number, edge: 'top' | 'bottom'): EdgeBlurMask {
+/**
+ * Mask geometry for a backdrop whose chrome sits at `edge` and whose feather faces the content.
+ * `fadeInside` is how far the feather reaches back into the chrome; chrome whose own text runs
+ * to its edge (the two-line chat identity) passes 0 so that text stays over solid blur.
+ */
+export function edgeBlurMask(chromeHeight: number, edge: 'top' | 'bottom', fadeInside: number = EDGE_BLUR_FADE_INSIDE): EdgeBlurMask {
const height = chromeHeight + EDGE_BLUR_FADE_OUTSIDE;
- const fadeLength = Math.min(EDGE_BLUR_FADE_INSIDE, chromeHeight / 2) + EDGE_BLUR_FADE_OUTSIDE;
+ const fadeLength = Math.min(fadeInside, chromeHeight / 2) + EDGE_BLUR_FADE_OUTSIDE;
const fadeFraction = fadeLength / height;
return edge === 'top'
? {
@@ -49,3 +53,27 @@ export function edgeBlurMask(chromeHeight: number, edge: 'top' | 'bottom'): Edge
endPoint: { x: 0.5, y: fadeFraction },
};
}
+
+/** The header feather reaches further than the composer's, closer to the system soft scroll edge. */
+export const HEADER_BLUR_FADE_OUTSIDE = spacing.xl;
+/** Each of the three stacked header layers; together they read about as strong as one 55 layer. */
+export const HEADER_BLUR_LAYER_INTENSITY = 32;
+/** Where each layer's feather ends, as a share of the whole fade. */
+const HEADER_BLUR_LAYER_REACH = [1 / 3, 2 / 3, 1] as const;
+
+/**
+ * Top chrome only: a progressive blur. Three equal blur layers start fading at the same point and
+ * finish at a third, two thirds and the end of the fade, so the blur itself thins toward the
+ * content instead of one sharp layer cross-fading over a clear one (which reads as a double image).
+ */
+export function headerBlurLayers(chromeHeight: number, fadeInside: number = EDGE_BLUR_FADE_INSIDE): EdgeBlurMask[] {
+ const height = chromeHeight + HEADER_BLUR_FADE_OUTSIDE;
+ const fadeLength = Math.min(fadeInside, chromeHeight / 2) + HEADER_BLUR_FADE_OUTSIDE;
+ const start = 1 - fadeLength / height;
+ return HEADER_BLUR_LAYER_REACH.map((reach) => ({
+ height,
+ colors: FADE_STOPS,
+ startPoint: { x: 0.5, y: start },
+ endPoint: { x: 0.5, y: start + reach * fadeLength / height },
+ }));
+}
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index 0d24a890ae..b3369fe23c 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -593,6 +593,13 @@ download happens in the normal startup Splash, not in the row.
### Mobile iOS navigation chrome / iPhone Duo
+- Home modes are ordered tabs: Tasks on the left, Teammates on the right (owner decision, 2026-10-13). All mode-selection entry points, including drawer tabs and title scope menus, use the same horizontal slide via HomeModePanes / HomeModeTransition. Switching to Teammates moves content left; switching back moves it right. One shared progress owned by `ResidentHomeListProvider` drives the panes and the wide resident task list over the same slide distance; it moves on the critically damped spring registered in §14.4. Retain both visited lists and their positions, retarget interrupted slides from the current position, and snap for reduced/unknown motion preference or initial preference restoration. The resident list follows without remounting; inactive pages cannot intercept touches or accessibility focus. This is a selection transition, not a new horizontal gesture that competes with list controls.
+- Home menu attention is a **6pt visible dot**, not a numeric badge. The normal and attention menu images share a transparent 26pt canvas with the same centered narrow 20pt glyph, so attention never shifts the menu artwork or changes the native hit target. Use semantic template tint in both modes; do not use an empty Stack.Toolbar.Badge (the current header bridge creates a large string badge). Duo uses the same template; the Android teammate fallback uses the same 6pt dot diameter. Numeric counts and connection/list status dots keep their separate roles and sizes.
+
+- Task and Teammate home share the iOS navigation container, menu control and centered-title width through HomeStackHeader (2026-10-13). The bar's measured-height blur is drawn once by HomeModePanes outside the sliding panes, because the native bar itself does not slide. Only the active home pane registers native chrome; hidden panes keep their content state. The home menu uses the slightly narrower three-line template in assets/navigation/menu.svg (owner refinement, 2026-10-13); only artwork changes, not button geometry or hit targets. System toolbars own ordinary menu/create/action geometry, with the existing Duo top-left exception shared by both homes. **Title alignment is intentionally page-specific**: task scope titles retain their long-name toolbar avoidance, while the Teammates title stays centered. Shared chrome must not force the teammate title to inherit task alignment. The teammate list reserves the measured native bar height once, including its scroll indicator and refresh position. Android retains its existing fallback in this batch; chat, secondary-page and sheet headers are not claimed migrated.
+
+- Teammate and group chat headers (`ChatIdentityHeader`) keep their left-aligned identity (mark, name, one subtitle line) next to back (owner decision, 2026-10-13). Back is the task header's system `chevron.backward` (`NativeChromeBackButton`). The trailing to-do and settings actions stay **two separate glass circles** with their existing Lucide artwork (18pt); only their stroke rises to `CHAT_HEADER_GLYPH_STROKE` (`iconStroke.medium`, about 1.65pt) so they read level with back — do not group them into one capsule or swap their artwork. On iOS the header floats on the same feathered `SessionHeaderNativeBlur` as the task header and content scrolls beneath it; an opaque header band is not allowed because its hard bottom edge reads as a divider. Because the two-line identity runs to the header's lower edge, chat headers keep the whole header over solid blur and feather only below it (`CHAT_HEADER_BLUR_FADE_INSIDE = 0`); single-line task and home bars keep the default 24pt inside feather. All iOS header blurs are progressive (owner request, 2026-10-13, to approach the softer system scroll edge on Settings): three equal layers (`HEADER_BLUR_LAYER_INTENSITY`) start fading together and finish at one third, two thirds and the end of the fade, which reaches `HEADER_BLUR_FADE_OUTSIDE` (24pt) past the chrome edge, so the blur thins toward content instead of one layer cross-fading into a double image. The composer's bottom blur keeps its single 55 layer. Android keeps its existing header.
+
- Explicitly selecting Teammates in the mobile home or chat drawer opens the teammate list, even with one teammate or when Teammates is already active. The mode switch itself never enters a chat; picking a teammate opens it. Keep cold-start recovery of a verified remembered teammate separate from this explicit navigation. Teammate rows share the task list typography: 18pt medium (500) titles with 28pt line height, 15pt regular previews with 26pt line height, and 13pt metadata with 22pt line height.
- Wide Home and task-sidebar presentations share one native list instance in `ResidentHomeListProvider`, outside route lifetimes. Route slots supply layout and callbacks; do not key the host by task/route or restore a cached offset over its live scroll position. Collapse/expand its bounds, keep native headers outside its touch area, and pause hidden row subscriptions. Narrow screens retain their route-local list.
@@ -1085,6 +1092,8 @@ long duration to leak into any other hover or transition.
**Mobile list disclosure rhythm (owner request, 2026-09-30).** On mobile, expanding and collapsing list groups (home pinned / shared / project / conversation groups, automation run groups on the home and device pages, the collapsible Settings debug group) and task-row moves from archive, unarchive, pin or unpin (rows leaving stay visible while the rows below close over them, then fade) follow the iOS system list rhythm instead of the Desktop `base` tier (200ms): 225ms quadratic ease-out with no overshoot, reaching about 90% of the travel within 150ms (the owner asked for the first 450ms version to be halved the same day). The group opens from under its header: list cells clip their content while their position and height animate, new rows sit at their final positions and are revealed as the group grows, and the rows below move down in step; new rows do not fade in place. Collapsing reverses this: removed rows stay visible while the group closes over them and fade only near the end. The disclosure chevron switches without animation. The duration lives in mobile's `listDisclosureMotion` token and the shared implementation is `apps/mobile/src/session/listDisclosureTransition.tsx` (Reanimated layout animations, attached only during the transition window; React Native `LayoutAnimation` is a no-op in this app because Reanimated owns the Fabric mounting layer). Reduced motion switches instantly. This exception does not apply to Desktop, sheets, dialogs, or other panels.
+**Mobile home mode slide (owner request, 2026-10-13).** Switching the mobile home between Tasks (left) and Teammates (right) — from the drawer or the title menu — slides the content horizontally on a critically damped spring (mass 1, stiffness 320, damping 36, overshoot clamped: about a 0.35s response, no visible bounce) instead of a duration tier. A reversal mid-slide is retargeted from the current position without restarting an ease-in-out, so it responds at once and a short remaining distance settles quickly. The parameters live in `HOME_MODE_SLIDE_SPRING` (`apps/mobile/src/session/HomeModeTransition.ts`). The navigation bar, its title and its blur do not slide. Reduced or not-yet-known motion preference switches instantly. This exception does not apply to any other surface.
+
**Mobile image viewer edge elasticity (owner request, 2026-10-10).** In the mobile full-screen image viewer (`apps/mobile/src/session/ImageLightbox.tsx`), direct manipulation follows the system Photos physics instead of hard stops: a zoomed one-finger pan may run past the image edge with rubber-band resistance (UIScrollView coefficient 0.55 over the container size), and a pinch may overshoot 1x / the maximum zoom with the same resistance. On release, anything out of bounds returns on a near-critically damped spring (no visible oscillation, about 0.3s); an in-bounds release continues with inertial decay that may briefly overrun the edge and return; a touch catches it in place. Scale and translation settle on the same spring so the point under the fingers stays put. These are physics responses to the hand, not duration-tier transitions, so they use spring/decay parameters rather than motion tokens; the parameters and decisions live in `imageLightboxModel.ts`. A single image at 1x keeps the native horizontal edge bounce. This exception does not apply to any other surface.
**macOS menu bar quota fill (owner request, 2026-10-11).** The native menu bar panel (`apps/desktop/native/menubar/`) fills its usage tubes and detail rings from empty over 0.5s with `timingCurve(0.22, 1, 0.36, 1)` (no overshoot) each time the panel opens or a page loads; page switches use the same curve and duration. This is a one-shot loading reveal in SwiftUI, not a Web duration tier: the Web tokens do not apply inside the native helper. Reduced motion shows the final values without animation. This exception does not apply to any other surface.
diff --git a/docs/design-rules/design-decision-log.md b/docs/design-rules/design-decision-log.md
index 61a0da5dbb..b0d8ad787c 100644
--- a/docs/design-rules/design-decision-log.md
+++ b/docs/design-rules/design-decision-log.md
@@ -10,6 +10,16 @@
> 2026-07-25 起 `§15` CINDY 皮肤族的决策史(红色体系重构、caret 改稿、vibrancy
> 定稿等)已随 §15 保号重构迁入本文件,`DESIGN.md §15` 只保留现行规范。
+## 2026-10-13
+
+- **伙伴私聊与群聊顶栏对齐任务详情:系统返回、两个独立圆钮、渐隐模糊底**——用户指出这两个聊天页的返回按钮、右上两个图标的粗细、以及顶栏下方的“分割线”都和任务详情不同。身份区按用户裁决保持靠左;返回改为与任务详情相同的系统箭头。右上待办、设置一度被合进一个玻璃胶囊并换成系统图标,用户否决:保留两个独立圆钮和原有图标,只把线宽从约 1.5pt 调到约 1.65pt。所谓分割线并不是画出来的线,而是顶栏底色不透明:私聊用实色底盖住了任务页同款的渐隐模糊,群聊顶栏与消息区上下分开,消息在顶栏下沿被直接切断。现在 iOS 上两者都浮在任务页同款的渐隐模糊上,消息从下面滚过。删除了从未接入的 `CompanionBackButton`。同日追加:用户截图指出聊天页模糊开始得太高,名字下方副标题旁的消息文字仍清晰可见。原因是通用模糊从顶栏下沿往上 24pt 开始变淡,而聊天顶栏是两行身份信息,副标题正落在变淡段。聊天顶栏改为整段保持完全模糊,只在下沿以外 16pt 内渐隐;任务页和首页的单行顶栏不变。同日再追加:用户认为设置页(系统柔和滚动边缘)的过渡更柔和。差别在于自绘顶栏只有一层固定强度的模糊,靠透明度淡出,过渡区里清楚的字和模糊的影子叠在一起;系统效果是模糊程度本身逐渐减弱。iOS 所有页面的顶栏模糊改为三层等强度模糊叠加,逐层提前淡出,形成渐进效果,外侧渐隐从 16pt 拉长到 24pt;底部输入框的模糊不变。
+
+- **任务/伙伴滑动改用临界阻尼弹簧,顶部模糊固定不随页面滑动**——review 发现两处问题:一是原 250ms 先慢后快再慢的曲线,在快速反向切换时会从零开始慢起步,剩余距离很短时也要重走整段时长;二是模糊背景跟着页面一起滑动,离开的一页立刻失去模糊,滑动途中顶部半边模糊、半边清晰。现改用不回弹的临界阻尼弹簧,并作为移动端例外登记在 DESIGN.md §14.4;模糊由 HomeModePanes 在滑动层外统一绘制一层。滑动进度只保留 ResidentHomeListProvider 这一处来源,左右两页与宽屏任务列表使用同一滑动距离。
+
+- **任务/伙伴作为左右页签滑动切换,菜单提示点收口为 6pt**——用户指出直接切换缺乏左右 tab 的方向感,且标题下拉选择也应同样转场。所有入口由 HomeModePanes 统一横向滑动,任务在左、伙伴在右;保留列表状态、快速反向及减弱动态效果降级。用户截图中的大黑点来自 iOS header 将空 Badge 作为文字徽章创建;改用固定 6pt 圆点的模板图,普通、Duo 和 Android 伙伴入口统一可见点尺寸,计数徽章保持原有角色。现行依据见 DESIGN.md §5。
+
+- **iOS 两个首页共用导航组件,伙伴标题允许独立对齐**——用户指出任务、伙伴菜单按钮与顶部高度不一致,并要求真正复用组件。批准首批改造时明确伙伴标题可与任务采用不同对齐规则。两个首页共用 HomeStackHeader,任务长名称避让与伙伴居中分别由标题内容负责;伙伴新建使用系统工具栏,隐藏首页不注册导航项,保留抽屉、未读提示与创建语义。现行规则见 DESIGN.md §5 与 Mobile 设计指南。首批只覆盖 iOS 两个首页,其他页面后续处理;不代表实机视觉验收通过。
+
## 2026-10
- **10-13 手机端自动化组展开箭头移到标题后**——用户反馈手机首页 / 设备页的定时任务分组展开后,子任务看起来比上面的分组更靠左,层级容易误读。原因是组行把展开箭头放在行首,箭头列把组行图标与标题推右约 30pt(标题 94pt),而子行只比普通行多缩进 16pt(标题 80pt)。现行:箭头紧跟组行标题(与桌面 `AutomationSessionGroupItem` 一致),仍是独立热区;组行图标 / 标题与同级普通任务对齐(项目内标题 64pt),子行比组行深一档,「查看全部 N 次运行」继续对齐子行文字。被取代:行首箭头(与项目组行首 chevron 对齐的旧做法)。落点:`apps/mobile/src/session/HomeSurface.tsx` 的 `sessionGroupChevronCell`。