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): 宽屏(iPad/安卓折叠屏/横屏)会话页三条杠 + 任务列表抽屉 (#1328)

Chris Zhang5b257b52c69e
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index 21bcc365a0..ed7e312eac 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -12,6 +12,7 @@ import {
Image,
List,
ListTodo,
+ Menu,
Mic,
Pencil,
Pin,
@@ -32,11 +33,12 @@ import {
setAudioModeAsync,
} from 'expo-audio';
import { useFocusEffect, useLocalSearchParams, useRouter } from 'expo-router';
-import { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode, type SetStateAction } from 'react';
+import { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode, type RefObject, type SetStateAction } from 'react';
import {
ActivityIndicator,
Alert,
AppState,
+ Keyboard,
KeyboardAvoidingView,
Linking,
Platform,
@@ -60,6 +62,7 @@ import { ScreenBackButton } from '@/components/MobilePrimitives';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { useAuth } from '@/auth/AuthContext';
import { useGuardedBack } from '@/utils/useGuardedBack';
+import { useGuardedPush } from '@/utils/useGuardedPush';
import { DEVICE_LINK_API_BASE_URL, MOBILE_VISUAL_MOCK_ENABLED } from '@/config/env';
import { ConnectionBanner, useShowConnectionBanner } from '@/components/ConnectionBanner';
import { resolveEffectiveConnectionError } from '@/components/connectionBannerVisibility';
@@ -395,6 +398,9 @@ import { deferScheduleIndexHydration } from '@/session/scheduleIndexDefer';
import { markSessionScheduleRunsRead, unreadRunIdFromProjection } from '@/session/scheduleRunRead';
import { useRemoteScheduleEventSnapshot } from '@/scheduler/remoteScheduleEvents';
import { buildSessionNativeShellLayout } from '@/session/mobileNativeShellLayout';
+import { buildWideSessionNavLayout } from '@/session/wideSessionNav';
+import { SessionListDrawer } from '@/session/SessionListDrawer';
+import type { RemoteSessionListItem } from '@/session/sessionList';
import {
findMobileMessageSearchHits,
nextMessageSearchIndex,
@@ -1914,6 +1920,68 @@ export default function SessionScreen() {
const composerTouchLayout = useMemo(() => buildComposerTouchLayout({
screenWidth: windowDimensions.width,
}), [windowDimensions.width]);
+ // 宽屏导航形态(iPad / 安卓折叠屏与横屏大屏机):左上角三条杠 + 任务列表抽屉,
+ // 原地 replace 切任务;窄屏保持传统返回键。断点与按平台分闸(iOS 仅 iPad,
+ // iPhone 不发)见 wideSessionNav.ts。
+ const wideSessionNav = useMemo(() => buildWideSessionNavLayout({
+ iosPad: Platform.OS === 'ios' && Platform.isPad,
+ platform: Platform.OS,
+ windowHeight: windowDimensions.height,
+ windowWidth: windowDimensions.width,
+ }), [windowDimensions.height, windowDimensions.width]);
+ const [sessionListDrawerOpen, setSessionListDrawerOpen] = useState(false);
+ // 三条杠按钮 ref:抽屉关闭后读屏焦点归还的锚点(SessionListDrawer.returnFocusRef)。
+ const sessionListButtonRef = useRef<View>(null);
+ // 旋转 / 分屏收窄回到窄屏形态时,抽屉没有入口也没有意义,直接关掉。
+ useEffect(() => {
+ if (!wideSessionNav.enabled) setSessionListDrawerOpen(false);
+ }, [wideSessionNav.enabled]);
+ const openSessionListDrawer = useCallback(() => {
+ Keyboard.dismiss();
+ setSessionListDrawerOpen(true);
+ }, []);
+ const closeSessionListDrawer = useCallback(() => setSessionListDrawerOpen(false), []);
+ const handleDrawerSelectSession = useCallback((item: RemoteSessionListItem) => {
+ const targetSession = item.session as RemoteSession;
+ if (targetSession.id === sessionId) {
+ setSessionListDrawerOpen(false);
+ return;
+ }
+ // 可达优先,与首页 openSession 同口径:被认领的 stale 会话优先 canonicalDeviceId,
+ // 回退物理 id / store 索引。校验先于关闭动画:失败时保持抽屉打开 + Alert 反馈
+ // (文案与首页同键)——先关再弹会让 200ms 后的读屏焦点归还从错误弹窗手里抢焦点,
+ // 且抽屉留在原地,用户可直接改选别的任务。
+ const targetDeviceId = targetSession.canonicalDeviceId
+ ?? targetSession.deviceLinkDeviceId
+ ?? remoteSessionStore.getSessionDeviceId(targetSession.id);
+ if (!targetDeviceId) {
+ Alert.alert(t('devices.list.error.sessionDeviceNotFound'));
+ return;
+ }
+ setSessionListDrawerOpen(false);
+ // replace 而非 push:抽屉是「原地切换」语义,栈保持 [主页, 会话],返回手势仍回主页。
+ router.replace({
+ pathname: '/sessions/[sessionId]',
+ params: {
+ deviceId: targetDeviceId,
+ deviceName: targetSession.deviceLinkDeviceName ?? targetDeviceId,
+ sessionId: targetSession.id,
+ },
+ });
+ }, [router, sessionId, t]);
+ // 前进导航防连点:快速双击「新建」会把 /sessions/new 压栈两层(返回要退两次),
+ // 与首页各入口同一把 guardedPush 锁。
+ const guardedPush = useGuardedPush();
+ const handleDrawerNewSession = useCallback(() => {
+ setSessionListDrawerOpen(false);
+ guardedPush({ pathname: '/sessions/new', params: { deviceId, deviceName } });
+ }, [deviceId, deviceName, guardedPush]);
+ // 抽屉「主页」是显式的去处承诺,不是「返回」:从设备详情/自动化页进来时 back 只退一层,
+ // 会落在中间页。dismissTo 沿当前栈一路退到根页,栈里没有根页(深链冷启动)则推入。
+ const handleDrawerGoHome = useCallback(() => {
+ setSessionListDrawerOpen(false);
+ router.dismissTo('/');
+ }, [router]);
// 聚焦 / 面板打开 / 语音中呈现卡片形态(输入区全宽 + 底部工具排),其余保持单行简洁态。
// 注意不看 composerLayout.density:有草稿 / 会话运行中未聚焦时也应收回简洁态,
// 否则「拖回单行退出激活态」永远收不回去。
@@ -7526,7 +7594,12 @@ export default function SessionScreen() {
return (
<View style={styles.safeArea} testID="session.screen">
<KeyboardAvoidingView
+ // 抽屉开着时把背后内容从读屏树里摘掉:iOS 用 accessibilityElementsHidden
+ // (与抽屉侧 accessibilityViewIsModal 配对),Android 用 importantForAccessibility
+ // ——后者才对 TalkBack 生效(与 ComposerRichInput 的双平台配对惯例一致)。
+ accessibilityElementsHidden={sessionListDrawerOpen}
behavior={nativeShellLayout.keyboardAvoidingBehavior}
+ importantForAccessibility={sessionListDrawerOpen ? 'no-hide-descendants' : 'auto'}
keyboardVerticalOffset={nativeShellLayout.keyboardVerticalOffset}
style={styles.keyboard}
>
@@ -7540,6 +7613,8 @@ export default function SessionScreen() {
syncing={showSyncingIndicator}
messageCount={Math.max(messages.length, currentSession?._count?.messages ?? 0)}
onBack={goBackToHome}
+ onOpenSessionList={wideSessionNav.enabled ? openSessionListDrawer : undefined}
+ sessionListButtonRef={sessionListButtonRef}
onOpenFiles={() => {
if (!currentSession?.workingDir) return;
router.push({
@@ -8343,6 +8418,20 @@ export default function SessionScreen() {
</View>
</View>
</KeyboardAvoidingView>
+ {wideSessionNav.enabled ? (
+ // 树内 overlay(zIndex 40)盖住顶部 chrome 与底部 composer;树内层叠而非 Modal 的
+ // 取舍见 SessionListDrawer 头注释。
+ <SessionListDrawer
+ currentSessionId={sessionId}
+ onClose={closeSessionListDrawer}
+ onGoHome={handleDrawerGoHome}
+ onNewSession={handleDrawerNewSession}
+ onSelectSession={handleDrawerSelectSession}
+ open={sessionListDrawerOpen}
+ returnFocusRef={sessionListButtonRef}
+ width={wideSessionNav.drawerWidth}
+ />
+ ) : null}
</View>
);
}
@@ -8363,6 +8452,7 @@ function SessionHeaderBar({
messageCount,
onBack,
onOpenFiles,
+ onOpenSessionList,
onOpenSettings,
onOpenUsage,
onToggleSearch,
@@ -8372,6 +8462,7 @@ function SessionHeaderBar({
readOnlyReason,
remoteUnavailableReason,
searchOpen,
+ sessionListButtonRef,
title,
}: {
currentSession: RemoteSession | null;
@@ -8380,6 +8471,10 @@ function SessionHeaderBar({
syncing: boolean;
messageCount: number;
onBack(): void;
+ /** 宽屏导航形态下提供:左上角改为三条杠,点击拉出任务列表抽屉(替代返回)。 */
+ onOpenSessionList?: () => void;
+ /** 三条杠按钮 ref:抽屉关闭后读屏焦点归还的锚点。 */
+ sessionListButtonRef?: RefObject<View | null>;
onOpenFiles(): void;
onOpenSettings(): void;
onOpenUsage(): void;
@@ -8430,12 +8525,26 @@ function SessionHeaderBar({
return (
<View style={styles.sessionHeaderBar} testID="session.summary">
- <ScreenBackButton
- hitSlop={4}
- onPress={onBack}
- style={styles.sessionHeaderBackButton}
- testID="session.backButton"
- />
+ {onOpenSessionList ? (
+ // 宽屏(iPad / 折叠屏展开 / 横屏手机):三条杠拉任务列表抽屉,返回语义由抽屉里的
+ // 「主页」项与系统返回手势承担。
+ <SessionHeaderIconButton
+ accessibilityLabel={t('home.drawer.openA11y')}
+ active={false}
+ buttonRef={sessionListButtonRef}
+ hitSlop={4}
+ icon={Menu}
+ onPress={onOpenSessionList}
+ testID="session.sessionListButton"
+ />
+ ) : (
+ <ScreenBackButton
+ hitSlop={4}
+ onPress={onBack}
+ style={styles.sessionHeaderBackButton}
+ testID="session.backButton"
+ />
+ )}
<View style={styles.sessionHeaderTextBlock}>
<View style={styles.sessionHeaderTitleRow}>
@@ -8489,7 +8598,9 @@ function SessionHeaderIconButton({
accessibilityLabel,
active,
attention = false,
+ buttonRef,
disabled,
+ hitSlop,
icon: Icon,
onPress,
testID,
@@ -8498,7 +8609,11 @@ function SessionHeaderIconButton({
accessibilityLabel: string;
active?: boolean;
attention?: boolean;
+ /** 需要外部定位本钮时传入(如三条杠:抽屉关闭后读屏焦点归还锚点)。 */
+ buttonRef?: RefObject<View | null>;
disabled?: boolean;
+ /** 38×38 可见钮低于 44 触控底线时用它补热区(如左上角三条杠)。 */
+ hitSlop?: PressableProps['hitSlop'];
icon: SessionHeaderIcon;
onPress?: () => void;
testID: string;
@@ -8508,10 +8623,12 @@ function SessionHeaderIconButton({
const color = colors.textPrimary;
return (
<RouteActionButton
+ ref={buttonRef}
accessibilityHint={accessibilityHint}
accessibilityLabel={accessibilityLabel}
active={active}
disabled={disabled}
+ hitSlop={hitSlop}
onPress={onPress}
pressedStyle={styles.sessionHeaderIconPressed}
style={[
diff --git a/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts b/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts
index aef5b3d3b6..6c19c4c2fe 100644
--- a/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts
+++ b/apps/mobile/src/__tests__/sessionHeaderDesktopFirst.test.ts
@@ -68,6 +68,36 @@ describe('mobile session header desktop-first surface', () => {
expect(source).not.toContain('minHeight: 54');
});
+ it('switches the leading control to the session-list hamburger on wide-screen navigation', () => {
+ const source = readTextLf(resolve(process.cwd(), 'app/sessions/[sessionId].tsx'), 'utf8');
+
+ // 宽屏(iPad / 折叠屏展开 / 横屏手机)导航形态:断点判定走 wideSessionNav 纯函数,
+ // 左上角三条杠替代返回,抽屉原地 replace 切任务;窄屏保持 ScreenBackButton(上一用例已锁)。
+ expect(source).toContain("import { buildWideSessionNavLayout } from '@/session/wideSessionNav';");
+ expect(source).toContain("import { SessionListDrawer } from '@/session/SessionListDrawer';");
+ // 按平台分闸(发布策略):iOS 只发 iPad,iPhone 横屏也保持返回键;安卓纯宽度闸。
+ expect(source).toContain('iosPad: Platform.OS === \'ios\' && Platform.isPad,');
+ expect(source).toContain('platform: Platform.OS,');
+ expect(source).toContain('onOpenSessionList={wideSessionNav.enabled ? openSessionListDrawer : undefined}');
+ expect(source).toContain('icon={Menu}');
+ expect(source).toContain('testID="session.sessionListButton"');
+ expect(source).toContain('{onOpenSessionList ? (');
+ // 抽屉切任务是「原地切换」:replace 保持导航栈 [主页, 会话],不逐层压栈。
+ expect(source).toContain("pathname: '/sessions/[sessionId]'");
+ expect(source).toContain('const handleDrawerSelectSession = useCallback((item: RemoteSessionListItem) => {');
+ expect(source).toContain('router.replace({');
+ // 旋转 / 分屏收窄回窄屏时抽屉必须自动收起(没有入口的悬空 overlay)。
+ expect(source).toContain('if (!wideSessionNav.enabled) setSessionListDrawerOpen(false);');
+ // 打开抽屉先收键盘(树内 overlay 盖不住键盘)。
+ expect(source).toContain('Keyboard.dismiss();\n setSessionListDrawerOpen(true);');
+ // 读屏模态语义双平台配对:iOS accessibilityElementsHidden + Android importantForAccessibility
+ // (accessibilityViewIsModal 只对 iOS 生效,安卓优先发布不能漏 TalkBack)。
+ expect(source).toContain('accessibilityElementsHidden={sessionListDrawerOpen}');
+ expect(source).toContain("importantForAccessibility={sessionListDrawerOpen ? 'no-hide-descendants' : 'auto'}");
+ // 选任务失败路径:校验先于关闭动画——先关再弹 Alert 会让焦点归还抢走弹窗焦点。
+ expect(source).toContain("Alert.alert(t('devices.list.error.sessionDeviceNotFound'));\n return;\n }\n setSessionListDrawerOpen(false);");
+ });
+
it('keeps pending history access as a lightweight control without message counters', () => {
const source = readTextLf(resolve(process.cwd(), 'app/sessions/[sessionId].tsx'), 'utf8');
const start = source.indexOf('function MessageHistoryToggle');
diff --git a/apps/mobile/src/__tests__/sessionListDrawer.test.ts b/apps/mobile/src/__tests__/sessionListDrawer.test.ts
new file mode 100644
index 0000000000..2bdf349835
--- /dev/null
+++ b/apps/mobile/src/__tests__/sessionListDrawer.test.ts
@@ -0,0 +1,104 @@
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+import { describe, expect, it } from 'vitest';
+
+const readTextLf = (...args: Parameters<typeof readFileSync>): string =>
+ String(readFileSync(...args)).replace(/\r\n/g, '\n');
+
+/**
+ * 宽屏任务列表抽屉的设计与行为门(与 sessionHeaderDesktopFirst 同款源码字符串门):
+ * 本仓 mobile 测试体系是纯函数 + 源码门,没有组件渲染设施,关键交互约定用字符串锁住。
+ */
+describe('mobile session list drawer', () => {
+ const source = () =>
+ readTextLf(resolve(process.cwd(), 'src/session/SessionListDrawer.tsx'), 'utf8');
+
+ it('keeps the drawer on design-system tokens with zero shadows and binary radii', () => {
+ const text = source();
+ // 零阴影 + 无硬编码色(dark 模式红线);圆角只允许 token(pill / container)。
+ expect(text).not.toMatch(/shadow[A-Z]/);
+ expect(text).not.toContain('elevation:');
+ expect(text).not.toMatch(/#[0-9a-fA-F]{3,8}\b/);
+ expect(text).not.toMatch(/borderRadius:\s*\d/);
+ expect(text).toContain('borderRadius: radius.pill');
+ expect(text).toContain('borderRadius: radius.container');
+ // 主题接入模式:模块级 makeStyles + useThemedStyles,不用静态色。
+ expect(text).toContain('const makeStyles = (colors: ThemeColors) =>');
+ expect(text).toContain('useThemedStyles(makeStyles)');
+ });
+
+ it('respects the reduce-motion convention (only animate when explicitly false)', () => {
+ const text = source();
+ expect(text).toContain("import { useReduceMotionEnabled } from '@/hooks/useReduceMotion';");
+ expect(text).toContain('reduceMotion === false');
+ });
+
+ it('drives all motion through the shared motion tokens (no hardcoded durations)', () => {
+ const text = source();
+ // 动效全走 motionDuration/motionEasing 档位(review #1328):入场 enter+out、
+ // 退场 exit+in、回弹 fast+move、spinner 走 spinnerCycle 语义例外档。
+ expect(text).toContain('duration: motionDuration.enter');
+ expect(text).toContain('duration: motionDuration.exit');
+ expect(text).toContain('duration: motionDuration.fast');
+ expect(text).toContain('duration: motionDuration.spinnerCycle');
+ expect(text).toContain('Easing.bezier(...motionEasing.out)');
+ expect(text).toContain('Easing.bezier(...motionEasing.in)');
+ expect(text).toContain('Easing.bezier(...motionEasing.move)');
+ expect(text).not.toMatch(/duration:\s*\d/);
+ });
+
+ it('closes on Android hardware back and folds drag offset into the timing animation', () => {
+ const text = source();
+ expect(text).toContain("BackHandler.addEventListener('hardwareBackPress', () => {");
+ // 多处除以 panelWidth,宽度必须有正下限(除零保险,不寄托在调用方身上)。
+ expect(text).toContain('Math.max(1, width + insets.left)');
+ // 手势位移并回 progress:关闭动画从当前视觉位置继续,不跳帧。
+ expect(text).toContain('progress.value + dragX.value / panelWidth');
+ // 拖拽关闭只认「向左」意图:右拖 16pt 判失败,纵向 16pt 先到滚动优先(review #1328)。
+ expect(text).toContain('.activeOffsetX(-16)');
+ expect(text).toContain('.failOffsetX(16)');
+ expect(text).toContain('.failOffsetY([-16, 16])');
+ // 关闭动画期间 overlay 恒拦截,不放行点击穿透半透明 scrim(review #1328)。
+ expect(text).toContain('pointerEvents="auto"');
+ // 抽屉 presentation 必须带权威设备身份,防 canonicalDeviceId 被弱推断覆盖(review #1328)。
+ expect(text).toContain('devices: remoteSessionStore.getDeviceIdentity(),');
+ // 行内状态与标题兜底与首页同口径:pending/liveActivity 索引 + 已解析 unnamedLabel(review #1328)。
+ expect(text).toContain('remoteSessionStore.getPendingInteractions(session.id).length');
+ expect(text).toContain('remoteSessionStore.getSessionLiveActivity(session.id)');
+ expect(text).toContain("unnamedLabel: t('session.menu.unnamedTitle')");
+ // 底部主操作行触控目标 >=44。
+ expect(text).toContain('minHeight: 44,');
+ });
+
+ it('keeps the drawer aligned with the home list presentation pipeline', () => {
+ const text = source();
+ // 与首页同一套共享层口径:排序 / 置顶 / 自动化折叠 / Orca worker 过滤 / 右槽状态档位。
+ expect(text).toContain('excludeOrcaWorkerSessions(sessions)');
+ expect(text).toContain('buildMobileHomePresentation({');
+ expect(text).toContain('buildHomeSections(home, false, false)');
+ expect(text).toContain('resolveMobileSessionRightStatus({');
+ expect(text).toContain('buildRemoteSessionCardPreview(item, { running })');
+ expect(text).toContain('formatRemoteSessionSidebarTime(lastActivityAt)');
+ });
+
+ it('exposes stable testIDs and modal accessibility semantics', () => {
+ const text = source();
+ for (const testId of [
+ 'sessionDrawer.overlay',
+ 'sessionDrawer.scrim',
+ 'sessionDrawer.panel',
+ 'sessionDrawer.newSession',
+ 'sessionDrawer.home',
+ ]) {
+ expect(text).toContain(`testID="${testId}"`);
+ }
+ expect(text).toContain('accessibilityViewIsModal={open}');
+ expect(text).toContain("t('home.drawer.closeA11y')");
+ // 读屏焦点管理(review #1328):打开移焦到面板首控件,关闭归还三条杠;
+ // 导航型关闭(本屏已失焦)不归还,不抢新屏焦点。
+ expect(text).toContain('AccessibilityInfo.setAccessibilityFocus(node)');
+ expect(text).toContain('AccessibilityInfo.setAccessibilityFocus(returnNode)');
+ expect(text).toContain('ref={newSessionButtonRef}');
+ expect(text).toContain('if (!navigation.isFocused()) return;');
+ });
+});
diff --git a/apps/mobile/src/__tests__/wideSessionNav.test.ts b/apps/mobile/src/__tests__/wideSessionNav.test.ts
new file mode 100644
index 0000000000..5828093d26
--- /dev/null
+++ b/apps/mobile/src/__tests__/wideSessionNav.test.ts
@@ -0,0 +1,63 @@
+import { describe, expect, it } from 'vitest';
+import {
+ WIDE_SESSION_NAV_MIN_WIDTH,
+ buildWideSessionNavLayout,
+} from '@/session/wideSessionNav';
+
+describe('buildWideSessionNavLayout', () => {
+ it('keeps portrait phones on the classic back-button navigation', () => {
+ // iPhone SE / 15 Pro / 16 Pro Max 竖屏与 iPad 窄分屏(约 1/3)都必须回退返回键。
+ for (const windowWidth of [320, 375, 393, 440]) {
+ expect(buildWideSessionNavLayout({ windowHeight: 852, windowWidth })).toEqual({
+ drawerWidth: 0,
+ enabled: false,
+ });
+ }
+ });
+
+ it('enables drawer navigation for iPad both orientations', () => {
+ // iPad mini 竖屏(744)/ iPad Pro 横屏(1366)。
+ expect(buildWideSessionNavLayout({ iosPad: true, platform: 'ios', windowHeight: 1133, windowWidth: 744 }).enabled).toBe(true);
+ expect(buildWideSessionNavLayout({ iosPad: true, platform: 'ios', windowHeight: 1024, windowWidth: 1366 }).enabled).toBe(true);
+ // iPad 窄分屏(~1/3)回退返回键。
+ expect(buildWideSessionNavLayout({ iosPad: true, platform: 'ios', windowHeight: 1024, windowWidth: 320 }).enabled).toBe(false);
+ });
+
+ it('keeps iPhone on back-button navigation even in landscape (per-platform rollout)', () => {
+ // 发布策略:iOS 只发 iPad;iPhone 横屏达宽也不启用宽屏形态。
+ expect(buildWideSessionNavLayout({ iosPad: false, platform: 'ios', windowHeight: 393, windowWidth: 852 }).enabled).toBe(false);
+ expect(buildWideSessionNavLayout({ platform: 'ios', windowHeight: 393, windowWidth: 852 }).enabled).toBe(false);
+ });
+
+ it('enables drawer navigation for unfolded foldables even in portrait (android)', () => {
+ // Pixel Fold 内屏竖持(约 648×672)——宽度已达 medium 档,不要求 landscape。
+ const layout = buildWideSessionNavLayout({ platform: 'android', windowHeight: 672, windowWidth: 648 });
+ expect(layout.enabled).toBe(true);
+ });
+
+ it('enables drawer navigation for android landscape phones', () => {
+ const layout = buildWideSessionNavLayout({ platform: 'android', windowHeight: 393, windowWidth: 852 });
+ expect(layout.enabled).toBe(true);
+ });
+
+ it('clamps drawer width to a readable range', () => {
+ // 断点下缘:0.4×600=240 < 300,顶到下限。
+ expect(buildWideSessionNavLayout({ windowHeight: 900, windowWidth: 600 }).drawerWidth).toBe(300);
+ // 大屏:0.4×1366=546 > 360,压到上限。
+ expect(buildWideSessionNavLayout({ windowHeight: 1024, windowWidth: 1366 }).drawerWidth).toBe(360);
+ // 区间内按比例取整。
+ expect(buildWideSessionNavLayout({ windowHeight: 1133, windowWidth: 800 }).drawerWidth).toBe(320);
+ });
+
+ it('treats missing or invalid dimensions as narrow (fail closed to back button)', () => {
+ expect(buildWideSessionNavLayout({}).enabled).toBe(false);
+ expect(buildWideSessionNavLayout({ windowHeight: Number.NaN, windowWidth: Number.NaN }).enabled).toBe(false);
+ expect(buildWideSessionNavLayout({ windowHeight: 800, windowWidth: -1 }).enabled).toBe(false);
+ });
+
+ it('keeps the breakpoint constant aligned with the documented medium window class', () => {
+ expect(WIDE_SESSION_NAV_MIN_WIDTH).toBe(600);
+ expect(buildWideSessionNavLayout({ windowHeight: 900, windowWidth: 599 }).enabled).toBe(false);
+ expect(buildWideSessionNavLayout({ windowHeight: 900, windowWidth: 600 }).enabled).toBe(true);
+ });
+});
diff --git a/apps/mobile/src/i18n/locales/en/home.json b/apps/mobile/src/i18n/locales/en/home.json
index 0967ef424b..f383067019 100644
--- a/apps/mobile/src/i18n/locales/en/home.json
+++ b/apps/mobile/src/i18n/locales/en/home.json
@@ -1 +1,8 @@
-{}
+{
+ "drawer": {
+ "openA11y": "Open session list",
+ "closeA11y": "Close session list",
+ "home": "Home",
+ "empty": "No sessions yet"
+ }
+}
diff --git a/apps/mobile/src/i18n/locales/ja/home.json b/apps/mobile/src/i18n/locales/ja/home.json
index 0967ef424b..d07d5b0c06 100644
--- a/apps/mobile/src/i18n/locales/ja/home.json
+++ b/apps/mobile/src/i18n/locales/ja/home.json
@@ -1 +1,8 @@
-{}
+{
+ "drawer": {
+ "openA11y": "セッション一覧を開く",
+ "closeA11y": "セッション一覧を閉じる",
+ "home": "ホーム",
+ "empty": "セッションはまだありません"
+ }
+}
diff --git a/apps/mobile/src/i18n/locales/ko/home.json b/apps/mobile/src/i18n/locales/ko/home.json
index 0967ef424b..007fde9020 100644
--- a/apps/mobile/src/i18n/locales/ko/home.json
+++ b/apps/mobile/src/i18n/locales/ko/home.json
@@ -1 +1,8 @@
-{}
+{
+ "drawer": {
+ "openA11y": "세션 목록 열기",
+ "closeA11y": "세션 목록 닫기",
+ "home": "홈",
+ "empty": "아직 세션이 없습니다"
+ }
+}
diff --git a/apps/mobile/src/i18n/locales/zh-CN/home.json b/apps/mobile/src/i18n/locales/zh-CN/home.json
index 0967ef424b..ed4f6c2206 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/home.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/home.json
@@ -1 +1,8 @@
-{}
+{
+ "drawer": {
+ "openA11y": "打开任务列表",
+ "closeA11y": "关闭任务列表",
+ "home": "主页",
+ "empty": "暂无任务"
+ }
+}
diff --git a/apps/mobile/src/session/SessionListDrawer.tsx b/apps/mobile/src/session/SessionListDrawer.tsx
new file mode 100644
index 0000000000..283fd2ec43
--- /dev/null
+++ b/apps/mobile/src/session/SessionListDrawer.tsx
@@ -0,0 +1,679 @@
+/**
+ * SessionListDrawer —— 宽屏(iPad / 折叠屏展开 / 横屏手机)会话页的任务列表抽屉。
+ *
+ * 会话页左上角三条杠拉出:原地切任务 / 新建任务 / 回主页,不来回压导航栈。
+ * 断点判定在 `wideSessionNav.ts`(纯函数),本组件只管呈现与手势。
+ *
+ * 结构取舍:
+ * - **树内 overlay 而非 RN Modal**:会话页已有多个 sheet Modal,iOS 同级双 Modal
+ * 有 present/dismiss 竞态(见 SheetSurface 头注释);树内层叠没有这些约束,选中任务
+ * 后可立即导航(replace 卸载整屏,无需等 Modal 关闭动画)。代价是盖不住原生弹层,
+ * 但抽屉打开前页面会先收键盘,且其它 sheet 与抽屉互斥(都由页面状态驱动)。
+ * - **数据直读全局 remoteSessionStore**:与首页同一份 store(进会话页前已水合,
+ * 设备订阅继续推增量),经共享层 buildMobileHomePresentation 复用首页的排序 /
+ * 置顶 / 自动化折叠口径,不在抽屉里重建首页的设备同步机械。
+ * - 动画走 reanimated(withTiming + Pan 手势拖拽关闭),遵循 reduce-motion 约定
+ * (useReduceMotionEnabled === false 才播)。
+ */
+import { House, LoaderCircle, SquarePen } from 'lucide-react-native';
+import { memo, useCallback, useEffect, useMemo, useRef, useState, type RefObject } from 'react';
+import {
+ AccessibilityInfo,
+ BackHandler,
+ findNodeHandle,
+ Pressable,
+ SectionList,
+ StyleSheet,
+ View,
+} from 'react-native';
+import Animated, {
+ cancelAnimation,
+ Easing,
+ runOnJS,
+ useAnimatedStyle,
+ useSharedValue,
+ withRepeat,
+ withTiming,
+} from 'react-native-reanimated';
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
+import { useNavigation } from 'expo-router';
+import { useTranslation } from 'react-i18next';
+import { Text } from '@/components/AppText';
+import { Gesture, GestureDetector } from '@/platform/gestureHandler';
+import { useReduceMotionEnabled } from '@/hooks/useReduceMotion';
+import { buildHomeSections, type HomeRow, type HomeSection } from '@/session/homeSections';
+import { buildMobileHomePresentation, excludeOrcaWorkerSessions } from '@/session/mobileHome';
+import {
+ remoteSessionStore,
+ useRemoteMessageVersion,
+ useRemoteSessions,
+ useRemoteSessionStoreVersion,
+ useSessionRunning,
+} from '@/session/remoteSessionStore';
+import type { RemoteSessionLiveActivity } from '@/session/sessionList';
+import { resolveMobileSessionRightStatus } from '@/session/sessionRightStatus';
+import {
+ buildRemoteSessionCardPreview,
+ buildSessionMessagePreviewIndex,
+ formatRemoteSessionSidebarTime,
+ type RemoteSessionListItem,
+} from '@/session/sessionList';
+import { useMinuteNow } from '@/utils/useMinuteNow';
+import { useTheme, useThemedStyles, type ThemeColors } from '@/theme';
+import {
+ fontWeight,
+ iconSize,
+ iconStroke,
+ lineHeight,
+ motionDuration,
+ motionEasing,
+ radius,
+ spacing,
+ typeScale,
+} from '@/theme/tokens';
+
+/** 拖过面板宽度的 1/3 或甩速超阈即判定关闭(常见抽屉手感)。 */
+const DRAWER_CLOSE_DISTANCE_RATIO = 1 / 3;
+const DRAWER_CLOSE_VELOCITY = -800;
+
+export function SessionListDrawer({
+ currentSessionId,
+ onClose,
+ onGoHome,
+ onNewSession,
+ onSelectSession,
+ open,
+ returnFocusRef,
+ width,
+}: {
+ currentSessionId: string;
+ onClose(): void;
+ onGoHome(): void;
+ onNewSession(): void;
+ onSelectSession(item: RemoteSessionListItem): void;
+ open: boolean;
+ /** 关闭后读屏焦点归还的触发钮(左上角三条杠);切任务导航整屏卸载时不消费。 */
+ returnFocusRef?: RefObject<View | null>;
+ width: number;
+}) {
+ const styles = useThemedStyles(makeStyles);
+ const { colors } = useTheme();
+ const { t } = useTranslation();
+ const insets = useSafeAreaInsets();
+ const reduceMotion = useReduceMotionEnabled();
+ // 抽屉贴左缘,横屏刘海侧的 left inset 并进面板总宽,内容用 padding 让出。
+ // 下限 1 是除零保险:当前调用点 enabled=false 时本组件整个不渲染(width 恒 >=300),
+ // 但 progress/scrim 多处除以 panelWidth,不把不变量寄托在调用方身上。
+ const panelWidth = Math.max(1, width + insets.left);
+
+ const [mounted, setMounted] = useState(open);
+ const mountedRef = useRef(mounted);
+ mountedRef.current = mounted;
+ const openRef = useRef(open);
+ openRef.current = open;
+ // progress 0→1 = 收起→展开;dragX(≤0)是手势拖拽的临时位移,松手后归零或并入 progress。
+ const progress = useSharedValue(open ? 1 : 0);
+ const dragX = useSharedValue(0);
+ // 关闭收尾统一走这里(动画完成回调 / reduce-motion 直跳两条路径):卸载 overlay 并把
+ // 读屏焦点还给触发钮——三条杠在抽屉打开期间被遮罩挡住,不还焦点会落在任意节点。
+ const navigation = useNavigation();
+ const finishClose = useCallback(() => {
+ if (openRef.current) return;
+ setMounted(false);
+ // 只有「原地关闭」(本屏仍聚焦)才归还焦点:导航型关闭(新建 push / 深链下
+ // dismissTo 推入主页)收尾时本屏已失焦,把读屏焦点拉回背景页的三条杠会抢走
+ // 新屏焦点。isFocused 是确定性信号,不用枚举关闭原因。
+ if (!navigation.isFocused()) return;
+ const returnNode = returnFocusRef?.current ? findNodeHandle(returnFocusRef.current) : null;
+ if (returnNode != null) AccessibilityInfo.setAccessibilityFocus(returnNode);
+ }, [navigation, returnFocusRef]);
+ // 打开后把读屏焦点移进面板首控件(新建任务):背后内容已按模态摘出读屏树,不移焦
+ // VoiceOver/TalkBack 会停在已隐藏的节点上。延到入场动画结束再移,避免读出滑动中的几何。
+ const newSessionButtonRef = useRef<View>(null);
+ useEffect(() => {
+ if (!open) return;
+ const timer = setTimeout(() => {
+ const node = findNodeHandle(newSessionButtonRef.current);
+ if (node != null) AccessibilityInfo.setAccessibilityFocus(node);
+ }, motionDuration.enter);
+ return () => clearTimeout(timer);
+ }, [open]);
+
+ useEffect(() => {
+ // reduce-motion 约定:只有 === false 才播动画,null(首帧未知)按不播降级。
+ const animate = reduceMotion === false;
+ if (open) {
+ setMounted(true);
+ // 手势位移并回 progress,从当前视觉位置继续,不跳帧。
+ const effective = Math.max(0, Math.min(1, progress.value + dragX.value / panelWidth));
+ progress.value = effective;
+ dragX.value = 0;
+ // 重浮层入场档(motionDuration.enter + out 曲线),与 DESIGN.md §14.4 双端同构。
+ progress.value = animate
+ ? withTiming(1, { duration: motionDuration.enter, easing: Easing.bezier(...motionEasing.out) })
+ : 1;
+ return;
+ }
+ if (!mountedRef.current) return;
+ const effective = Math.max(0, Math.min(1, progress.value + dragX.value / panelWidth));
+ progress.value = effective;
+ dragX.value = 0;
+ if (!animate) {
+ progress.value = 0;
+ finishClose();
+ return;
+ }
+ progress.value = withTiming(
+ 0,
+ // 重浮层退场档(motionDuration.exit + in 曲线)。
+ { duration: motionDuration.exit, easing: Easing.bezier(...motionEasing.in) },
+ (finished) => {
+ 'worklet';
+ if (finished) runOnJS(finishClose)();
+ },
+ );
+ }, [dragX, finishClose, open, panelWidth, progress, reduceMotion]);
+
+ // Android 系统返回键:抽屉开着时先关抽屉,不冒泡成页面返回。
+ useEffect(() => {
+ if (!open) return;
+ const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
+ onClose();
+ return true;
+ });
+ return () => subscription.remove();
+ }, [onClose, open]);
+
+ const closeFromGesture = useCallback(() => onClose(), [onClose]);
+ const panGesture = useMemo(
+ () =>
+ Gesture.Pan()
+ // 与内部 SectionList 纵向滚动的协调全靠激活窗口收窄:
+ // - 只认「向左」(关闭方向)为激活条件,向右 16pt 直接判失败——右拖不该抢任何手势;
+ // - 纵向 16pt 先到即失败,滚动优先;斜向手势必须横向分量先赢才归抽屉。
+ .activeOffsetX(-16)
+ .failOffsetX(16)
+ .failOffsetY([-16, 16])
+ .onUpdate((event) => {
+ 'worklet';
+ dragX.value = Math.min(0, event.translationX);
+ })
+ .onEnd((event) => {
+ 'worklet';
+ const shouldClose =
+ event.translationX < -panelWidth * DRAWER_CLOSE_DISTANCE_RATIO ||
+ event.velocityX < DRAWER_CLOSE_VELOCITY;
+ if (shouldClose) {
+ runOnJS(closeFromGesture)();
+ } else {
+ // 未过阈回弹:位置插值档(fast + move 曲线)。
+ dragX.value = withTiming(0, {
+ duration: motionDuration.fast,
+ easing: Easing.bezier(...motionEasing.move),
+ });
+ }
+ }),
+ [closeFromGesture, dragX, panelWidth],
+ );
+
+ const scrimStyle = useAnimatedStyle(() => ({
+ opacity: Math.max(0, Math.min(1, progress.value + dragX.value / panelWidth)),
+ }));
+ const panelStyle = useAnimatedStyle(() => ({
+ transform: [
+ {
+ translateX: Math.max(
+ -panelWidth,
+ Math.min(0, (progress.value - 1) * panelWidth + dragX.value),
+ ),
+ },
+ ],
+ }));
+
+ // 与首页同一套展示模型(排序 / 置顶区 / 自动化折叠);未挂载时跳过重建,
+ // 常驻宽屏页面时不为收起的抽屉付 presentation 成本。
+ const sessions = useRemoteSessions();
+ // storeVersion / messageVersion:pending 交互、liveActivity、消息镜像都不在 sessions
+ // 数组身份里,靠版本号驱动重算(与首页三个 index 的依赖口径一致);未挂载时 memo
+ // 早退,不为收起的抽屉付这份成本。
+ const storeVersion = useRemoteSessionStoreVersion();
+ const messageVersion = useRemoteMessageVersion();
+ const sections = useMemo<HomeSection[]>(() => {
+ if (!mounted) return [];
+ void storeVersion;
+ void messageVersion;
+ // 已 load 会话的预览走消息镜像(applyRemotePush 只追加镜像、不回写 session.preview,
+ // 缺这个索引会让「坐在会话页期间别的任务来了新消息」的摘要停在旧值);未打开过的
+ // 会话由 presentation 内部回退 session.preview,与首页同一套兜底链。
+ const messagePreviewIndex = buildSessionMessagePreviewIndex(
+ sessions.map((session) => session.id),
+ (sessionId) => remoteSessionStore.getMessages(sessionId),
+ );
+ // 与首页同口径的行内状态输入:等待授权/回复(awaiting)与 live error/done 都来自
+ // 这两个 index,缺了会全部退化成普通时间行。
+ const pendingInteractionIndex = new Map(
+ sessions
+ .map((session) => [session.id, remoteSessionStore.getPendingInteractions(session.id).length] as const)
+ .filter(([, count]) => count > 0),
+ );
+ const liveActivityEntries: Array<[string, RemoteSessionLiveActivity]> = [];
+ for (const session of sessions) {
+ const liveActivity = remoteSessionStore.getSessionLiveActivity(session.id);
+ if (liveActivity) liveActivityEntries.push([session.id, liveActivity]);
+ }
+ const home = buildMobileHomePresentation({
+ // 权威设备身份必须随会话一起进 presentation:canonicalizeSessionDevice 会按传入
+ // devices 重算并覆盖 canonicalDeviceId,空列表会把 store 已认领好的规范 id 打回
+ // 弱推断(re-link 后点行路由到旧物理设备)。store 身份变化会触发 sessions 重算,
+ // 本 memo 以 sessions 为依赖即可保持同步。
+ devices: remoteSessionStore.getDeviceIdentity(),
+ liveActivityIndex: new Map(liveActivityEntries),
+ messagePreviewIndex,
+ pendingInteractionIndex,
+ // scheduleIndex **刻意不接**:它靠 1+N×listRuns RPC 水合,仓内把这条链路限制在
+ // 首页/设备详情页并配 defer+30s 节流(见 scheduleIndex.ts / scheduleIndexDefer.ts,
+ // issue 324:单 WS 管道被背景 listRuns 拥塞会拖慢会话打开的关键读)。抽屉是瞬态
+ // 切换器:分组与名称由共享层 fallbackScheduleInfo 兜底,主选与运行态由
+ // pendingInteractionIndex / liveActivity / useSessionRunning 覆盖,仅缺 schedule
+ // 未读绿点这档次要徽标——不值得从会话页新开一个取数点。
+ sessions: excludeOrcaWorkerSessions(sessions),
+ statusFilter: 'active',
+ // 已解析的 i18n 文案传给共享层(共享层不出中文串;en/ja/ko 不再回退「未命名任务」)。
+ unnamedLabel: t('session.menu.unnamedTitle'),
+ });
+ return buildHomeSections(home, false, false);
+ }, [messageVersion, mounted, sessions, storeVersion, t]);
+ const hasRows = useMemo(
+ () => sections.some((section) => section.data.length > 0),
+ [sections],
+ );
+
+ const renderRow = useCallback(
+ ({ item }: { item: HomeRow }) => {
+ if (item.kind !== 'session') return null;
+ const active =
+ item.item.session.id === currentSessionId ||
+ (item.item.automationGroup?.sessionIds.includes(currentSessionId) ?? false);
+ return (
+ <DrawerSessionRow
+ active={active}
+ item={item.item}
+ onSelect={onSelectSession}
+ />
+ );
+ },
+ [currentSessionId, onSelectSession],
+ );
+
+ if (!mounted) return null;
+
+ return (
+ <View
+ // iOS VoiceOver:抽屉开着时按模态处理,不让焦点跑到被遮住的会话内容上。
+ accessibilityViewIsModal={open}
+ // mounted 期间恒拦截(含 200ms 关闭动画):此时 scrim 仍半透明盖着内容,放行
+ // 点击会穿透误触;落在 scrim 上的点击只是幂等地再触发一次 onClose。
+ pointerEvents="auto"
+ style={styles.overlay}
+ testID="sessionDrawer.overlay"
+ >
+ <Animated.View style={[styles.scrim, scrimStyle]}>
+ <Pressable
+ accessibilityLabel={t('home.drawer.closeA11y')}
+ accessibilityRole="button"
+ onPress={onClose}
+ style={styles.scrimPressable}
+ testID="sessionDrawer.scrim"
+ />
+ </Animated.View>
+ <GestureDetector gesture={panGesture}>
+ <Animated.View
+ style={[
+ styles.panel,
+ { paddingLeft: insets.left, paddingTop: insets.top + spacing.sm, width: panelWidth },
+ panelStyle,
+ ]}
+ testID="sessionDrawer.panel"
+ >
+ <View style={styles.panelHeader}>
+ <Text numberOfLines={1} style={styles.panelTitle} testID="sessionDrawer.title">
+ {t('devices.list.allConversations')}
+ </Text>
+ <Pressable
+ accessibilityLabel={t('devices.list.a11y.newRemoteConversation')}
+ accessibilityRole="button"
+ hitSlop={6}
+ onPress={onNewSession}
+ ref={newSessionButtonRef}
+ style={({ pressed }) => [styles.panelIconButton, pressed && styles.pressed]}
+ testID="sessionDrawer.newSession"
+ >
+ <SquarePen
+ color={colors.textPrimary}
+ size={iconSize.xl}
+ strokeWidth={iconStroke.regular}
+ />
+ </Pressable>
+ </View>
+ {hasRows ? (
+ <SectionList
+ contentContainerStyle={styles.listContent}
+ keyExtractor={(row) => row.key}
+ keyboardShouldPersistTaps="handled"
+ renderItem={renderRow}
+ renderSectionHeader={({ section }) =>
+ section.title ? (
+ <Text style={styles.sectionTitle}>{section.title}</Text>
+ ) : null
+ }
+ sections={sections}
+ showsVerticalScrollIndicator={false}
+ stickySectionHeadersEnabled={false}
+ style={styles.list}
+ testID="sessionDrawer.list"
+ />
+ ) : (
+ <View style={styles.emptyState}>
+ <Text style={styles.emptyStateText}>{t('home.drawer.empty')}</Text>
+ </View>
+ )}
+ <View style={[styles.footer, { paddingBottom: insets.bottom + spacing.sm }]}>
+ <Pressable
+ accessibilityLabel={t('home.drawer.home')}
+ accessibilityRole="button"
+ onPress={onGoHome}
+ style={({ pressed }) => [styles.footerRow, pressed && styles.pressed]}
+ testID="sessionDrawer.home"
+ >
+ <House
+ color={colors.textSecondary}
+ size={iconSize.lg}
+ strokeWidth={iconStroke.regular}
+ />
+ <Text style={styles.footerLabel}>{t('home.drawer.home')}</Text>
+ </Pressable>
+ </View>
+ </Animated.View>
+ </GestureDetector>
+ </View>
+ );
+}
+
+const DrawerSessionRow = memo(function DrawerSessionRow({
+ active,
+ item,
+ onSelect,
+}: {
+ active: boolean;
+ item: RemoteSessionListItem;
+ onSelect(item: RemoteSessionListItem): void;
+}) {
+ const styles = useThemedStyles(makeStyles);
+ const { colors } = useTheme();
+ const { t } = useTranslation();
+ // 运行态走订阅(行 memo 化后命令式读取会 stale,与首页行同一取舍)。
+ const sessionIsRunning = useSessionRunning(item.session.id);
+ const running = sessionIsRunning || !!item.scheduleInfo?.running;
+ const rightStatus = resolveMobileSessionRightStatus({
+ liveAttention: item.liveActivity?.attention === true,
+ livePhase: item.liveActivity?.phase,
+ pendingInteractionCount: item.pendingInteractionCount,
+ running,
+ scheduleUnreadCount: item.scheduleInfo?.unreadCount ?? 0,
+ });
+ const preview = buildRemoteSessionCardPreview(item, { running });
+ return (
+ <Pressable
+ accessibilityLabel={t('devices.list.a11y.openConversation', { title: item.title })}
+ accessibilityRole="button"
+ accessibilityState={{ selected: active }}
+ onPress={() => onSelect(item)}
+ style={({ pressed }) => [styles.row, active && styles.rowActive, pressed && styles.pressed]}
+ testID={`sessionDrawer.row.${item.session.id}`}
+ >
+ <View style={styles.rowTitleLine}>
+ <Text numberOfLines={1} style={styles.rowTitle}>
+ {item.title}
+ </Text>
+ {rightStatus === 'time' ? (
+ <DrawerRelativeTime lastActivityAt={item.lastActivityAt} />
+ ) : (
+ <View style={styles.rowStatusCell}>
+ {rightStatus === 'running' ? (
+ <DrawerRowSpinner sessionId={item.session.id} />
+ ) : (
+ <View
+ accessibilityLabel={
+ rightStatus === 'error'
+ ? t('devices.list.a11y.taskError')
+ : rightStatus === 'awaiting'
+ ? t('devices.list.a11y.awaitingYou')
+ : t('devices.list.a11y.doneUnread')
+ }
+ accessibilityRole="image"
+ style={[
+ styles.rowStatusDot,
+ {
+ backgroundColor:
+ rightStatus === 'error'
+ ? colors.statusError
+ : rightStatus === 'awaiting'
+ ? colors.statusAwaiting
+ : colors.statusDone,
+ },
+ ]}
+ testID={`sessionDrawer.rowStatus.${rightStatus}.${item.session.id}`}
+ />
+ )}
+ </View>
+ )}
+ </View>
+ {preview?.trim() ? (
+ <Text numberOfLines={1} style={styles.rowPreview}>
+ {preview}
+ </Text>
+ ) : null}
+ </Pressable>
+ );
+});
+
+function DrawerRelativeTime({ lastActivityAt }: { lastActivityAt: string }) {
+ const styles = useThemedStyles(makeStyles);
+ useMinuteNow();
+ return (
+ <Text numberOfLines={1} style={styles.rowTime}>
+ {formatRemoteSessionSidebarTime(lastActivityAt)}
+ </Text>
+ );
+}
+
+/** 与首页右槽同款:LoaderCircle 圆弧 1s 匀速旋转,中性色。 */
+function DrawerRowSpinner({ sessionId }: { sessionId: string }) {
+ const { colors } = useTheme();
+ const { t } = useTranslation();
+ const reduceMotion = useReduceMotionEnabled();
+ const turn = useSharedValue(0);
+ const animate = reduceMotion === false;
+ useEffect(() => {
+ if (!animate) return;
+ turn.value = 0;
+ turn.value = withRepeat(
+ // spinnerCycle 是功能性 loading 的语义循环档(§14.4 窄例外),匀速不走缓动曲线。
+ withTiming(1, { duration: motionDuration.spinnerCycle, easing: Easing.linear }),
+ -1,
+ false,
+ );
+ return () => {
+ cancelAnimation(turn);
+ turn.value = 0;
+ };
+ }, [animate, turn]);
+ const spinStyle = useAnimatedStyle(() => ({
+ transform: [{ rotate: `${turn.value * 360}deg` }],
+ }));
+ return (
+ <Animated.View
+ accessibilityLabel={t('devices.list.a11y.running')}
+ style={spinStyle}
+ testID={`sessionDrawer.rowStatus.running.${sessionId}`}
+ >
+ <LoaderCircle
+ color={colors.textTertiary}
+ size={iconSize.md}
+ strokeWidth={iconStroke.regular}
+ />
+ </Animated.View>
+ );
+}
+
+const makeStyles = (colors: ThemeColors) =>
+ StyleSheet.create({
+ overlay: {
+ ...StyleSheet.absoluteFill,
+ zIndex: 40,
+ },
+ scrim: {
+ ...StyleSheet.absoluteFill,
+ backgroundColor: colors.overlay,
+ },
+ scrimPressable: {
+ flex: 1,
+ },
+ panel: {
+ backgroundColor: colors.surface,
+ borderRightColor: colors.border,
+ borderRightWidth: StyleSheet.hairlineWidth,
+ bottom: 0,
+ left: 0,
+ position: 'absolute',
+ top: 0,
+ },
+ panelHeader: {
+ alignItems: 'center',
+ flexDirection: 'row',
+ gap: spacing.sm,
+ justifyContent: 'space-between',
+ paddingHorizontal: spacing.lg,
+ paddingVertical: spacing.sm,
+ },
+ panelTitle: {
+ color: colors.textPrimary,
+ flexShrink: 1,
+ fontSize: typeScale.title,
+ fontWeight: fontWeight.medium,
+ lineHeight: lineHeight.subtitle,
+ },
+ // 38×38 与会话头图标钮同规格,热区经 hitSlop 补到 44。
+ panelIconButton: {
+ alignItems: 'center',
+ borderRadius: radius.pill,
+ height: 38,
+ justifyContent: 'center',
+ width: 38,
+ },
+ list: {
+ flex: 1,
+ },
+ listContent: {
+ paddingBottom: spacing.lg,
+ paddingHorizontal: spacing.sm,
+ },
+ sectionTitle: {
+ color: colors.textTertiary,
+ fontSize: typeScale.caption,
+ fontWeight: fontWeight.medium,
+ lineHeight: lineHeight.caption,
+ paddingHorizontal: spacing.sm,
+ paddingBottom: spacing.xs,
+ paddingTop: spacing.md,
+ },
+ row: {
+ borderRadius: radius.container,
+ // 标题与预览行距 2pt 微调:xs(4) 会把双行行高撑过 56,列表密度掉档。
+ gap: 2,
+ // 无预览的单行任务行只有 42(22+20),minHeight 补足 44 触控底线;居中让单行不顶格。
+ justifyContent: 'center',
+ minHeight: 44,
+ paddingHorizontal: spacing.sm,
+ // sm+2 微调:凑出双行行高 ≈56 的触控行,md(12) 会松成 60+。
+ paddingVertical: spacing.sm + 2,
+ },
+ rowActive: {
+ backgroundColor: colors.surfaceChip,
+ },
+ rowTitleLine: {
+ alignItems: 'center',
+ flexDirection: 'row',
+ gap: spacing.sm,
+ minWidth: 0,
+ },
+ rowTitle: {
+ color: colors.textPrimary,
+ flex: 1,
+ fontSize: typeScale.body,
+ fontWeight: fontWeight.medium,
+ lineHeight: lineHeight.body,
+ minWidth: 0,
+ },
+ rowTime: {
+ color: colors.textTertiary,
+ flexShrink: 0,
+ fontSize: typeScale.caption,
+ lineHeight: lineHeight.caption,
+ },
+ // 18×18 定位槽 + 10pt 状态点:与首页会话行右槽同规格(点/spinner 先居中同一槽再对齐)。
+ rowStatusCell: {
+ alignItems: 'center',
+ flexShrink: 0,
+ height: 18,
+ justifyContent: 'center',
+ width: 18,
+ },
+ rowStatusDot: {
+ borderRadius: radius.pill,
+ height: 10,
+ width: 10,
+ },
+ rowPreview: {
+ color: colors.textTertiary,
+ fontSize: typeScale.caption,
+ lineHeight: lineHeight.caption,
+ },
+ emptyState: {
+ alignItems: 'center',
+ flex: 1,
+ justifyContent: 'center',
+ padding: spacing.xl,
+ },
+ emptyStateText: {
+ color: colors.textTertiary,
+ fontSize: typeScale.body,
+ lineHeight: lineHeight.body,
+ textAlign: 'center',
+ },
+ footer: {
+ borderTopColor: colors.border,
+ borderTopWidth: StyleSheet.hairlineWidth,
+ paddingHorizontal: spacing.sm,
+ paddingTop: spacing.sm,
+ },
+ footerRow: {
+ alignItems: 'center',
+ borderRadius: radius.container,
+ flexDirection: 'row',
+ gap: spacing.sm,
+ // 主操作行触控目标 >=44(iOS HIG):内容 22 + padV 16 只有 38,minHeight 补足。
+ minHeight: 44,
+ paddingHorizontal: spacing.sm,
+ paddingVertical: spacing.sm,
+ },
+ footerLabel: {
+ color: colors.textSecondary,
+ fontSize: typeScale.body,
+ fontWeight: fontWeight.medium,
+ lineHeight: lineHeight.body,
+ },
+ pressed: {
+ opacity: 0.72,
+ },
+ });
diff --git a/apps/mobile/src/session/remoteSessionStore.ts b/apps/mobile/src/session/remoteSessionStore.ts
index 7fef48da03..30a8130f26 100644
--- a/apps/mobile/src/session/remoteSessionStore.ts
+++ b/apps/mobile/src/session/remoteSessionStore.ts
@@ -1202,6 +1202,16 @@ function recallParkedTaskUpdates(
}
export const remoteSessionStore = {
+ /**
+ * 读当前权威设备身份列表(setDeviceIdentity 注入的那份;未注入过为空)。
+ * 会话页抽屉等在首页之外调 buildMobileHomePresentation 时传入,保证展示归一化
+ * (canonicalDeviceId 认领)与首页/本 store 同一口径——不传 devices 的空列表会把
+ * store 已算好的规范 id 覆盖成仅凭会话内嵌名字推出的弱结果(re-link 后路由错设备)。
+ */
+ getDeviceIdentity(): readonly { deviceId: string; name: string }[] {
+ return deviceList ?? [];
+ },
+
// 注入当前权威设备列表(首页从 /api/device-link/devices reconcile 后调用),用于设备身份归一化。
// 仅在身份索引实际变化时重算,避免每次设备列表引用变动都刷新全部会话。
setDeviceIdentity(devices: readonly { deviceId: string; name: string }[]): void {
diff --git a/apps/mobile/src/session/wideSessionNav.ts b/apps/mobile/src/session/wideSessionNav.ts
new file mode 100644
index 0000000000..9202f3ca1d
--- /dev/null
+++ b/apps/mobile/src/session/wideSessionNav.ts
@@ -0,0 +1,67 @@
+/**
+ * wideSessionNav —— 会话页宽屏导航模式的断点判定(纯函数,便于单测)。
+ *
+ * 宽屏(iPad 双向 / 折叠屏展开内屏 / 横屏手机)下会话页左上角不再是「返回」,
+ * 而是三条杠(Menu):点击拉出任务列表抽屉,原地切换任务,不来回压导航栈。
+ *
+ * 断点口径与仓内另外两套是三种不同语义,不合并:
+ * - `responsiveViewportLayout.wideViewport`(>=700 或 landscape)管的是**内容可读宽度**,
+ * 小手机横屏也要限宽,所以 landscape 一律算宽;
+ * - `loginSkinLayout`(1000×690 / 700)管的是登录页立绘皮肤的三态;
+ * - 本文件管的是**导航形态**:600dp 取 Material 3 的 medium 窗口档,恰好覆盖
+ * iPad 竖屏(768+)、主流折叠屏展开内屏(约 600-680dp,竖持也 >=600)与横屏手机
+ * (>=640),同时排除所有竖屏直板手机(<=约 440)与 iPad 窄分屏(~320,此时回退
+ * 返回键模式是正确行为)。不额外要求 landscape:折叠屏内屏竖持宽度已达标,
+ * 要求横向反而把它漏掉。
+ *
+ * 发布策略按平台分闸(2026-08-02 用户定稿):
+ * - Android:纯宽度闸——折叠屏展开 / 平板 / 横屏大屏机都启用;
+ * - iOS:仅 iPad(iosPad)启用;iPhone 即使横屏达宽也**不发**,保持返回键
+ * (评审风险面最小,后续要放开 iPhone 横屏只改这一处)。
+ */
+
+export const WIDE_SESSION_NAV_MIN_WIDTH = 600;
+
+const DRAWER_MIN_WIDTH = 300;
+const DRAWER_MAX_WIDTH = 360;
+const DRAWER_WIDTH_RATIO = 0.4;
+
+export interface WideSessionNavLayoutInput {
+ windowWidth?: number;
+ windowHeight?: number;
+ /** Platform.OS。iOS 有 iPad 专属闸;其余平台(android/web)纯宽度闸。 */
+ platform?: string;
+ /** iOS 下是否 iPad(Platform.isPad)。iPhone 恒 false → 宽屏形态不启用。 */
+ iosPad?: boolean;
+}
+
+export interface WideSessionNavLayout {
+ /** true = 会话页用三条杠 + 任务列表抽屉;false = 传统返回键。 */
+ enabled: boolean;
+ /** 抽屉面板宽度(enabled 为 false 时给 0,调用方不消费)。 */
+ drawerWidth: number;
+}
+
+export function buildWideSessionNavLayout(
+ input: WideSessionNavLayoutInput,
+): WideSessionNavLayout {
+ const windowWidth = normalizeDimension(input.windowWidth);
+ // iOS 只对 iPad 发宽屏形态;iPhone(含横屏)按发布策略回退返回键。
+ const platformAllowed = input.platform !== 'ios' || input.iosPad === true;
+ const enabled = platformAllowed && windowWidth >= WIDE_SESSION_NAV_MIN_WIDTH;
+ if (!enabled) return { drawerWidth: 0, enabled };
+ const drawerWidth = clamp(
+ Math.round(windowWidth * DRAWER_WIDTH_RATIO),
+ DRAWER_MIN_WIDTH,
+ DRAWER_MAX_WIDTH,
+ );
+ return { drawerWidth, enabled };
+}
+
+function normalizeDimension(value: number | undefined): number {
+ return Number.isFinite(value) && value !== undefined && value > 0 ? value : 0;
+}
+
+function clamp(value: number, min: number, max: number): number {
+ return Math.min(Math.max(value, min), max);
+}
diff --git a/docs/design-previews/mobile-wide-session-drawer/index.html b/docs/design-previews/mobile-wide-session-drawer/index.html
new file mode 100644
index 0000000000..12e9433c16
--- /dev/null
+++ b/docs/design-previews/mobile-wide-session-drawer/index.html
@@ -0,0 +1,418 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+<meta charset="UTF-8">
+<title>Cindy Mobile · 宽屏会话页三条杠 + 任务列表抽屉 预览</title>
+<style>
+ /* ── 色值 1:1 取自 apps/mobile/src/theme/tokens.ts(代码为真相源) ── */
+ :root {
+ --surface:#EDEDED; --surface-elevated:#F8F8F8; --surface-chip:#F1F1F1;
+ --border:#C6C9CE; --text-primary:#3C3F43; --text-secondary:#8C8E94; --text-tertiary:#686B72;
+ --overlay:rgba(38,38,38,.35);
+ --chat-header-surface:rgba(246,246,246,.90); --chat-header-divider:#DCDFE3;
+ --status-ready:#19D2C1; --status-accent:#EA6B17; --status-awaiting:#19D2C1;
+ --status-error:#D91F37; --status-done:#2AAE5B;
+ --cta:#3C3F43; --cta-text:#FCFCFC; --list-row:#F6F6F6;
+ }
+ .dark {
+ --surface:#2A2828; --surface-elevated:#312F2F; --surface-chip:#2F2D2D;
+ --border:#434343; --text-primary:#D4D4D4; --text-secondary:#6F6F6F; --text-tertiary:#BFC1C4;
+ --overlay:rgba(0,0,0,.45);
+ --chat-header-surface:rgba(37,35,35,.80); --chat-header-divider:rgba(255,255,255,.05);
+ --cta:#EEEEEE; --cta-text:#252222; --list-row:#312F2F;
+ }
+ * { box-sizing:border-box; margin:0; padding:0; -webkit-font-smoothing:antialiased; }
+ html,body { height:100%; }
+ body {
+ font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Helvetica Neue",sans-serif;
+ background:#1a1a1a; display:flex; flex-direction:column; align-items:center;
+ overflow:hidden; user-select:none;
+ }
+ /* ── 顶部控制条(预览工具自身,非 App UI) ── */
+ .toolbar {
+ display:flex; gap:8px; align-items:center; padding:10px 16px; flex-wrap:wrap;
+ justify-content:center; color:#999; font-size:12px;
+ }
+ .toolbar button {
+ background:#2c2c2c; color:#bbb; border:1px solid #3d3d3d; border-radius:999px;
+ padding:5px 14px; font-size:12px; cursor:pointer;
+ }
+ .toolbar button.on { background:#e8e8e8; color:#222; border-color:#e8e8e8; }
+ .stage { flex:1; display:flex; align-items:center; justify-content:center; width:100%; }
+
+ /* ── 设备框 ── */
+ .device {
+ position:relative; background:var(--surface); border-radius:24px; overflow:hidden;
+ box-shadow:0 20px 60px rgba(0,0,0,.55); outline:6px solid #0d0d0d;
+ transform-origin:center center;
+ }
+ .screen { position:absolute; inset:0; display:flex; flex-direction:column; }
+
+ /* ── 会话页:顶部 chrome(absolute, blur) ── */
+ .chrome {
+ position:absolute; left:0; right:0; top:0; z-index:10; overflow:hidden;
+ background:var(--chat-header-surface);
+ -webkit-backdrop-filter:blur(20px); backdrop-filter:blur(20px);
+ }
+ .header { /* sessionHeaderBar: minHeight 50 / padH 8 / padV 4 / gap 4 / hairline */
+ display:flex; align-items:center; gap:4px; min-height:50px;
+ padding:4px 8px; border-bottom:0.5px solid var(--chat-header-divider);
+ }
+ .icon-btn { /* SessionHeaderIconButton: 38×38 pill */
+ width:38px; height:38px; border-radius:999px; display:flex; align-items:center;
+ justify-content:center; flex-shrink:0; cursor:pointer; border:none; background:transparent;
+ }
+ .icon-btn:active { background:var(--surface-chip); }
+ .back-btn { /* ScreenBackButton: 44×44, marginLeft -8 */
+ width:44px; height:44px; margin-left:-8px; border-radius:999px; display:none;
+ align-items:center; justify-content:center; flex-shrink:0; cursor:pointer; border:none; background:transparent;
+ }
+ .narrow .back-btn { display:flex; }
+ .narrow .menu-btn { display:none; }
+ .header-text { flex:1; min-width:0; padding-left:4px; }
+ .header-title { /* body16 / semibold600 / lh22 */
+ font-size:16px; line-height:22px; font-weight:600; color:var(--text-primary);
+ white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
+ }
+ .header-notice { font-size:11px; line-height:14px; margin-top:2px; color:var(--text-secondary); }
+ .header-actions { display:flex; align-items:center; gap:2px; }
+ svg.ic { stroke:var(--text-primary); fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
+
+ /* ── 消息区(示意背景) ── */
+ .messages {
+ flex:1; overflow:hidden; padding:66px 0 96px;
+ display:flex; flex-direction:column; gap:14px; align-items:center;
+ }
+ .msg-col { width:100%; max-width:760px; padding:0 20px; display:flex; flex-direction:column; gap:14px; }
+ .bubble-user {
+ align-self:flex-end; max-width:78%; background:var(--surface-chip);
+ border:1px solid var(--border); border-radius:12px; padding:10px 14px;
+ font-size:16px; line-height:22px; color:var(--text-primary);
+ }
+ .assistant { font-size:16px; line-height:24px; color:var(--text-primary); }
+ .assistant .dim { color:var(--text-tertiary); font-size:13px; line-height:20px; display:block; margin-top:6px; }
+ .work-strip {
+ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text-tertiary);
+ }
+ .work-strip .flame { width:8px; height:8px; border-radius:999px; background:var(--status-accent);
+ animation:breathe 1.6s ease-in-out infinite; }
+ @keyframes breathe { 0%,100%{opacity:.35} 50%{opacity:1} }
+
+ /* ── 底部 composer(示意) ── */
+ .composer-layer { position:absolute; left:0; right:0; bottom:0; z-index:10; display:flex; justify-content:center; padding:0 16px 18px; }
+ .composer {
+ width:100%; max-width:760px; background:var(--surface-elevated); border:1px solid var(--border);
+ border-radius:999px; min-height:46px; display:flex; align-items:center; gap:10px; padding:0 8px 0 16px;
+ }
+ .composer .ph { flex:1; font-size:16px; color:var(--text-tertiary); }
+ .composer .send {
+ width:34px; height:34px; border-radius:999px; background:var(--cta); display:flex;
+ align-items:center; justify-content:center;
+ }
+ .composer .send svg { stroke:var(--cta-text); }
+
+ /* ── 抽屉 overlay(zIndex 40) ── */
+ .drawer-overlay { position:absolute; inset:0; z-index:40; visibility:hidden; }
+ .drawer-overlay.mounted { visibility:visible; }
+ .scrim { position:absolute; inset:0; background:var(--overlay); opacity:0; }
+ .panel {
+ position:absolute; left:0; top:0; bottom:0; background:var(--surface);
+ border-right:0.5px solid var(--border); display:flex; flex-direction:column;
+ padding-top:14px; /* insets.top(示意 6) + spacing.sm 8 */
+ transform:translateX(-100%); touch-action:pan-y;
+ }
+ .panel-header { /* padH 16 / padV 8 */
+ display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 16px;
+ }
+ .panel-title { font-size:20px; line-height:26px; font-weight:500; color:var(--text-primary); }
+ .drawer-list { flex:1; overflow-y:auto; padding:0 8px 16px; }
+ .section-title { /* caption12 / medium / tertiary */
+ font-size:12px; line-height:18px; font-weight:500; color:var(--text-tertiary);
+ padding:12px 8px 4px;
+ }
+ .row { /* radius 12 / padH 8 / padV 10 / gap 2 */
+ border-radius:12px; padding:10px 8px; display:flex; flex-direction:column; gap:2px; cursor:pointer;
+ }
+ .row:active { opacity:.72; }
+ .row.active { background:var(--surface-chip); }
+ .row-line1 { display:flex; align-items:center; gap:8px; min-width:0; }
+ .row-title {
+ flex:1; min-width:0; font-size:16px; line-height:22px; font-weight:500; color:var(--text-primary);
+ white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
+ }
+ .row-time { flex-shrink:0; font-size:12px; line-height:18px; color:var(--text-tertiary); }
+ .status-cell { width:18px; height:18px; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
+ .dot { width:10px; height:10px; border-radius:999px; }
+ .row-preview {
+ font-size:12px; line-height:18px; color:var(--text-tertiary);
+ white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
+ }
+ .spinner { animation:spin 1s linear infinite; display:flex; }
+ @keyframes spin { to { transform:rotate(360deg); } }
+ .drawer-footer { border-top:0.5px solid var(--border); padding:8px 8px 14px; }
+ .footer-row {
+ display:flex; align-items:center; gap:8px; border-radius:12px; padding:8px; cursor:pointer;
+ }
+ .footer-row:active { opacity:.72; }
+ .footer-label { font-size:16px; line-height:22px; font-weight:500; color:var(--text-secondary); }
+ .footer-row svg { stroke:var(--text-secondary); }
+ .hint {
+ color:#777; font-size:12px; padding:8px 16px 14px; text-align:center; line-height:1.7;
+ }
+ .hint b { color:#aaa; font-weight:500; }
+</style>
+</head>
+<body>
+ <div class="toolbar">
+ <span>设备:</span>
+ <button data-dev="ipad-l" class="on">iPad 横屏 1180×820</button>
+ <button data-dev="ipad-p">iPad 竖屏 820×1180</button>
+ <button data-dev="fold">安卓折叠屏展开 648×672</button>
+ <button data-dev="phone-l">安卓手机横屏 852×393</button>
+ <button data-dev="phone-p">手机竖屏 393×852(对照:回退返回键)</button>
+ <span style="width:12px"></span>
+ <button id="modeBtn">☀︎ Light</button>
+ </div>
+
+ <div class="stage"><div class="device" id="device">
+ <div class="screen" id="screen">
+ <!-- 顶部 chrome -->
+ <div class="chrome">
+ <div class="header">
+ <button class="back-btn" title="返回">
+ <svg class="ic" width="20" height="20" viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>
+ </button>
+ <button class="icon-btn menu-btn" id="menuBtn" title="打开任务列表">
+ <svg class="ic" width="20" height="20" viewBox="0 0 24 24">
+ <line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="18" y2="18"/>
+ </svg>
+ </button>
+ <div class="header-text">
+ <div class="header-title">移动端横屏与折叠屏适配</div>
+ <div class="header-notice">待处理 2</div>
+ </div>
+ <div class="header-actions">
+ <button class="icon-btn" title="文件">
+ <svg class="ic" width="20" height="20" viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>
+ </button>
+ <button class="icon-btn" title="搜索">
+ <svg class="ic" width="20" height="20" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
+ </button>
+ <button class="icon-btn" title="菜单">
+ <svg class="ic" width="20" height="20" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>
+ </button>
+ </div>
+ </div>
+ </div>
+
+ <!-- 消息区(示意) -->
+ <div class="messages"><div class="msg-col">
+ <div class="bubble-user">我们做一下移动端横屏和折叠屏适配吧,session 内页左上角改成三条杠,拉出任务列表。</div>
+ <div class="assistant">
+ 好的。宽屏(≥600dp)下左上角改为三条杠,点击从左缘拉出任务列表抽屉;列表复用首页的置顶区、
+ 排序与状态点口径,选任务原地切换、不压导航栈。
+ <span class="dim">已改 10 个文件 · 新增 wideSessionNav.ts / SessionListDrawer.tsx · 测试 57 项全绿</span>
+ </div>
+ <div class="work-strip"><span class="flame"></span>正在运行 pnpm --filter mobile typecheck…</div>
+ </div></div>
+
+ <!-- 底部 composer(示意) -->
+ <div class="composer-layer"><div class="composer">
+ <span class="ph">输入消息…</span>
+ <svg class="ic" width="20" height="20" viewBox="0 0 24 24" style="stroke:var(--text-secondary)"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></svg>
+ <div class="send"><svg class="ic" width="16" height="16" viewBox="0 0 24 24"><path d="m5 12 7-7 7 7"/><path d="M12 19V5"/></svg></div>
+ </div></div>
+
+ <!-- 任务列表抽屉 -->
+ <div class="drawer-overlay" id="overlay">
+ <div class="scrim" id="scrim" title="关闭任务列表"></div>
+ <div class="panel" id="panel">
+ <div class="panel-header">
+ <div class="panel-title">所有任务</div>
+ <button class="icon-btn" id="newBtn" title="新建远程任务">
+ <svg class="ic" width="22" height="22" viewBox="0 0 24 24"><path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"/></svg>
+ </button>
+ </div>
+ <div class="drawer-list">
+ <div class="section-title">置顶</div>
+ <div class="row">
+ <div class="row-line1"><span class="row-title">Cindy 客户端重构主线</span>
+ <span class="status-cell"><span class="dot" style="background:var(--status-done)"></span></span></div>
+ <div class="row-preview">P2 renderer 收尾:侧栏冷缓存已合并,等回归确认</div>
+ </div>
+ <div class="row">
+ <div class="row-line1"><span class="row-title">周报自动生成</span><span class="row-time">昨天</span></div>
+ <div class="row-preview">已生成 7-28 ~ 8-01 财务周报草稿</div>
+ </div>
+ <div class="section-title" style="padding-top:16px"></div>
+ <div class="row active">
+ <div class="row-line1"><span class="row-title">移动端横屏与折叠屏适配</span>
+ <span class="status-cell"><span class="spinner"><svg class="ic" width="16" height="16" viewBox="0 0 24 24" style="stroke:var(--text-tertiary)"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg></span></span></div>
+ <div class="row-preview">正在运行 pnpm --filter mobile typecheck…</div>
+ </div>
+ <div class="row">
+ <div class="row-line1"><span class="row-title">修复登录页冷启动闪退</span>
+ <span class="status-cell"><span class="dot" style="background:var(--status-awaiting)"></span></span></div>
+ <div class="row-preview">需要你确认:是否允许上报崩溃堆栈?</div>
+ </div>
+ <div class="row">
+ <div class="row-line1"><span class="row-title">数据库迁移脚本 v14</span>
+ <span class="status-cell"><span class="dot" style="background:var(--status-error)"></span></span></div>
+ <div class="row-preview">migration 校验失败:schema drift 于 sessions 表</div>
+ </div>
+ <div class="row">
+ <div class="row-line1"><span class="row-title">NAS 影视库整理</span><span class="row-time">3 天前</span></div>
+ <div class="row-preview">已入库 12 部,2 部字幕待匹配</div>
+ </div>
+ <div class="row">
+ <div class="row-line1"><span class="row-title">接口联调记录</span><span class="row-time">07-26</span></div>
+ <div class="row-preview">device-link 隧道 allowlist 增补完成</div>
+ </div>
+ <div class="row">
+ <div class="row-line1"><span class="row-title">竞品 UI 走查</span><span class="row-time">07-22</span></div>
+ <div class="row-preview">Kun / OpenCode 供应商预设对比结论已归档</div>
+ </div>
+ </div>
+ <div class="drawer-footer">
+ <div class="footer-row" id="homeRow">
+ <svg class="ic" width="18" height="18" viewBox="0 0 24 24"><path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/><path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>
+ <span class="footer-label">主页</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div></div>
+
+ <div class="hint">
+ 点 <b>三条杠</b> 拉出抽屉 · 点 <b>遮罩</b> 或在面板上 <b>向左拖</b>(超 1/3 或快甩)关闭 ·
+ 点任务行 = 原地切换(高亮行为当前任务) · 色值/尺寸/动效参数与 <b>tokens.ts / SessionListDrawer.tsx</b> 一致 ·
+ 手机竖屏预设展示窄屏回退的返回键形态<br>
+ 发布策略按平台分闸:<b>安卓</b>纯宽度闸(折叠屏/平板/横屏大屏机);<b>iOS 仅 iPad</b>,
+ iPhone 即使横屏达宽也不启用、保持返回键(见 wideSessionNav.ts)
+ </div>
+
+<script>
+ // ── 断点与抽屉宽度:与 wideSessionNav.ts 完全同式 ──
+ const WIDE_MIN = 600, DRAWER_MIN = 300, DRAWER_MAX = 360, RATIO = 0.4;
+ const clamp = (v, lo, hi) => Math.min(Math.max(v, lo), hi);
+ const drawerWidth = (w) => clamp(Math.round(w * RATIO), DRAWER_MIN, DRAWER_MAX);
+
+ const DEVICES = {
+ 'ipad-l': { w:1180, h:820 },
+ 'ipad-p': { w:820, h:1180 },
+ 'fold': { w:648, h:672 },
+ 'phone-l': { w:852, h:393 },
+ 'phone-p': { w:393, h:852 },
+ };
+ const device = document.getElementById('device');
+ const screenEl = document.getElementById('screen');
+ const overlay = document.getElementById('overlay');
+ const scrim = document.getElementById('scrim');
+ const panel = document.getElementById('panel');
+ let current = DEVICES['ipad-l'];
+ let panelW = drawerWidth(current.w);
+ let open = false;
+
+ // ── 动效:进 240ms Easing.out(cubic) / 出 200ms Easing.in(cubic) / 拖拽回弹 160ms ──
+ const EASE_OUT = 'cubic-bezier(0.33, 1, 0.68, 1)';
+ const EASE_IN = 'cubic-bezier(0.32, 0, 0.67, 0)';
+
+ function applyDevice(key) {
+ current = DEVICES[key];
+ panelW = drawerWidth(current.w);
+ device.style.width = current.w + 'px';
+ device.style.height = current.h + 'px';
+ panel.style.width = panelW + 'px';
+ const wide = current.w >= WIDE_MIN;
+ screenEl.classList.toggle('narrow', !wide);
+ setOpen(false, true); // 切设备 = 重挂载:抽屉收起(窄屏回退与页面 effect 一致)
+ // 缩放适配预览窗口
+ const stage = document.querySelector('.stage');
+ const scale = Math.min(1, (stage.clientWidth - 48) / current.w, (stage.clientHeight - 24) / current.h);
+ device.style.transform = `scale(${scale})`;
+ }
+
+ function setOpen(next, instant = false) {
+ if (next === open && !instant) return;
+ open = next;
+ if (next) {
+ overlay.classList.add('mounted');
+ panel.style.transition = `transform 240ms ${EASE_OUT}`;
+ scrim.style.transition = `opacity 240ms ${EASE_OUT}`;
+ requestAnimationFrame(() => requestAnimationFrame(() => {
+ panel.style.transform = 'translateX(0)';
+ scrim.style.opacity = '1';
+ }));
+ } else {
+ const ms = instant ? 0 : 200;
+ panel.style.transition = `transform ${ms}ms ${EASE_IN}`;
+ scrim.style.transition = `opacity ${ms}ms ${EASE_IN}`;
+ panel.style.transform = 'translateX(-100%)';
+ scrim.style.opacity = '0';
+ const unmount = () => { if (!open) overlay.classList.remove('mounted'); };
+ instant ? unmount() : setTimeout(unmount, ms);
+ }
+ }
+
+ document.getElementById('menuBtn').addEventListener('click', () => setOpen(true));
+ scrim.addEventListener('click', () => setOpen(false));
+ document.getElementById('homeRow').addEventListener('click', () => setOpen(false));
+ document.getElementById('newBtn').addEventListener('click', () => setOpen(false));
+ // 选任务:原地切换 —— 换高亮行 + 换页头标题,关抽屉
+ document.querySelectorAll('.row').forEach((row) => {
+ row.addEventListener('click', () => {
+ document.querySelectorAll('.row').forEach((r) => r.classList.remove('active'));
+ row.classList.add('active');
+ document.querySelector('.header-title').textContent = row.querySelector('.row-title').textContent;
+ setOpen(false);
+ });
+ });
+
+ // ── 面板拖拽关闭:dragX ≤ 0,松手 |dx| > 1/3 宽或速度超阈即关(与 Pan 手势同参) ──
+ let dragging = false, startX = 0, lastX = 0, lastT = 0, vx = 0;
+ panel.addEventListener('pointerdown', (e) => {
+ dragging = true; startX = lastX = e.clientX; lastT = performance.now(); vx = 0;
+ panel.style.transition = 'none'; scrim.style.transition = 'none';
+ panel.setPointerCapture(e.pointerId);
+ });
+ panel.addEventListener('pointermove', (e) => {
+ if (!dragging) return;
+ const now = performance.now();
+ vx = (e.clientX - lastX) / Math.max(1, now - lastT) * 1000; // px/s
+ lastX = e.clientX; lastT = now;
+ const dx = Math.min(0, e.clientX - startX);
+ panel.style.transform = `translateX(${dx}px)`;
+ scrim.style.opacity = String(Math.max(0, Math.min(1, 1 + dx / panelW)));
+ });
+ const endDrag = (e) => {
+ if (!dragging) return; dragging = false;
+ const dx = Math.min(0, e.clientX - startX);
+ if (dx < -panelW / 3 || vx < -800) { setOpen(false); }
+ else { // 回弹 160ms
+ panel.style.transition = `transform 160ms ${EASE_OUT}`;
+ scrim.style.transition = `opacity 160ms ${EASE_OUT}`;
+ panel.style.transform = 'translateX(0)'; scrim.style.opacity = '1';
+ }
+ };
+ panel.addEventListener('pointerup', endDrag);
+ panel.addEventListener('pointercancel', endDrag);
+
+ // ── 工具条 ──
+ document.querySelectorAll('[data-dev]').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ document.querySelectorAll('[data-dev]').forEach((b) => b.classList.remove('on'));
+ btn.classList.add('on');
+ applyDevice(btn.dataset.dev);
+ });
+ });
+ const modeBtn = document.getElementById('modeBtn');
+ modeBtn.addEventListener('click', () => {
+ const dark = device.classList.toggle('dark');
+ modeBtn.textContent = dark ? '☾ Dark' : '☀︎ Light';
+ });
+ window.addEventListener('resize', () => applyDevice(document.querySelector('[data-dev].on').dataset.dev));
+ applyDevice('ipad-l');
+</script>
+</body>
+</html>
diff --git a/docs/design-previews/mobile-wide-session-drawer/shots/01-ipad-landscape-light-closed.png b/docs/design-previews/mobile-wide-session-drawer/shots/01-ipad-landscape-light-closed.png
new file mode 100644
index 0000000000..6c8b367556
Binary files /dev/null and b/docs/design-previews/mobile-wide-session-drawer/shots/01-ipad-landscape-light-closed.png differ
diff --git a/docs/design-previews/mobile-wide-session-drawer/shots/02-ipad-landscape-light-drawer.png b/docs/design-previews/mobile-wide-session-drawer/shots/02-ipad-landscape-light-drawer.png
new file mode 100644
index 0000000000..1c6491053a
Binary files /dev/null and b/docs/design-previews/mobile-wide-session-drawer/shots/02-ipad-landscape-light-drawer.png differ
diff --git a/docs/design-previews/mobile-wide-session-drawer/shots/03-ipad-landscape-dark-drawer.png b/docs/design-previews/mobile-wide-session-drawer/shots/03-ipad-landscape-dark-drawer.png
new file mode 100644
index 0000000000..950acb63b9
Binary files /dev/null and b/docs/design-previews/mobile-wide-session-drawer/shots/03-ipad-landscape-dark-drawer.png differ
diff --git a/docs/design-previews/mobile-wide-session-drawer/shots/04-ipad-portrait-light-drawer.png b/docs/design-previews/mobile-wide-session-drawer/shots/04-ipad-portrait-light-drawer.png
new file mode 100644
index 0000000000..441a9f5f05
Binary files /dev/null and b/docs/design-previews/mobile-wide-session-drawer/shots/04-ipad-portrait-light-drawer.png differ
diff --git a/docs/design-previews/mobile-wide-session-drawer/shots/05-android-foldable-light-drawer.png b/docs/design-previews/mobile-wide-session-drawer/shots/05-android-foldable-light-drawer.png
new file mode 100644
index 0000000000..d43e38678b
Binary files /dev/null and b/docs/design-previews/mobile-wide-session-drawer/shots/05-android-foldable-light-drawer.png differ
diff --git a/docs/design-previews/mobile-wide-session-drawer/shots/06-android-phone-landscape-dark-drawer.png b/docs/design-previews/mobile-wide-session-drawer/shots/06-android-phone-landscape-dark-drawer.png
new file mode 100644
index 0000000000..648972cead
Binary files /dev/null and b/docs/design-previews/mobile-wide-session-drawer/shots/06-android-phone-landscape-dark-drawer.png differ
diff --git a/docs/design-previews/mobile-wide-session-drawer/shots/07-phone-portrait-light-back-fallback.png b/docs/design-previews/mobile-wide-session-drawer/shots/07-phone-portrait-light-back-fallback.png
new file mode 100644
index 0000000000..0f15f2c3cc
Binary files /dev/null and b/docs/design-previews/mobile-wide-session-drawer/shots/07-phone-portrait-light-back-fallback.png differ