Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(mobile): 双击任务标题直接改名,改名按钮不再被键盘遮挡
Dash6a6fce4011da
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsxindex 875d0169f7..615f08c68f 100644--- a/apps/mobile/app/sessions/[sessionId].tsx+++ b/apps/mobile/app/sessions/[sessionId].tsx@@ -12,6 +12,7 @@ import { SystemNavigationBack, useSystemNavigationBack } from '@/platform/chromeimport { keyboardControlRegion, type LayoutRect } from '@/platform/windowGeometry';import { useAdaptiveWindow, PaneViewportProvider } from '@/platform/AdaptiveWindowContext';import { useSessionHeaderHeight } from '@/session/useSessionHeaderHeight';+import { useDoubleTap } from '@/session/useDoubleTap';import { sessionPaneLayout } from '@/session/sessionPaneLayout';import { ComposerExpandButton } from '@/session/ComposerExpandButton';import { nativeComposerAvailable } from '@/session/ComposerNativeInput';@@ -208,7 +209,7 @@ import {SessionMenuSheet,type SessionExtraDirBrowserState,} from '@/session/SessionMenuSheet';-import type { SessionMenuView } from '@/session/sessionMenu';+import { sessionMenuAllowsRename, type SessionMenuView } from '@/session/sessionMenu';import { SessionSearchNative } from '@/session/SessionSearchNative';import { useHostManagedSession } from '@/session/hostManagedSession';import {@@ -9365,6 +9366,10 @@ export default function SessionScreen() {}}onOpenSettings={() => openSessionMenu('menu')}onOpenUsage={() => openSessionMenu('info')}+ onTitleDoubleTap={currentSession && !isDeviceAccessRevoked+ && sessionMenuAllowsRename(currentSession, sessionManagedByHost)+ ? () => openSessionMenu('rename')+ : undefined}onOpenRemoteDesktop={() => {if (!deviceId) return;guardedPush({@@ -10560,6 +10565,7 @@ function SessionHeaderBar({onOpenSettings,onOpenUsage,onOpenRemoteDesktop,+ onTitleDoubleTap,onToggleSearch,pendingCount,queueCount,@@ -10591,6 +10597,8 @@ function SessionHeaderBar({onOpenSettings(): void;onOpenUsage(): void;onOpenRemoteDesktop(): void;+ /** 双击标题直接打开重命名;不可重命名时不传。 */+ onTitleDoubleTap?: () => void;onToggleSearch(): void;pendingCount: number;queueCount: number;@@ -10636,6 +10644,8 @@ function SessionHeaderBar({session: currentSession,});const nativeHeader = Platform.OS === 'ios';+ const titleDoubleTap = sharedTaskEnded ? undefined : onTitleDoubleTap;+ const handleTitlePress = useDoubleTap(titleDoubleTap);const systemBack = useSystemNavigationBack();const headerWindow = useWindowDimensions();const headerInsets = useSafeAreaInsets();@@ -10669,6 +10679,7 @@ function SessionHeaderBar({minWidth: 0, flexShrink: 1, overflow: 'hidden', justifyContent: 'center' }}><SessionHeaderNativeTitle title={title} pinned={!messageOnly && !!currentSession?.pinnedAt}tags={isDeviceAccessRevoked ? undefined : currentSession?.tags} onTagsPress={onOpenSettings}+ onTitleDoubleTap={titleDoubleTap}syncing={syncing} syncingImmediately={syncingImmediately} notice={notice} /></View>),@@ -10739,12 +10750,15 @@ function SessionHeaderBar({title={sharedTaskEnded ? t('sharedTask.ended') : title}tags={isDeviceAccessRevoked ? undefined : currentSession?.tags}onTagsPress={onOpenSettings}+ onTitleDoubleTap={titleDoubleTap}pinned={!messageOnly && !!currentSession?.pinnedAt}syncing={syncing}syncingImmediately={syncingImmediately}notice={notice}/> : (- <View style={styles.sessionHeaderTextBlock}>+ // 双击标题改名;不参与读屏焦点,读屏用户从「任务详情」进入重命名。+ <Pressable accessible={false} disabled={!titleDoubleTap} onPress={handleTitlePress}+ style={styles.sessionHeaderTextBlock} testID="session.titleArea"><View style={styles.sessionHeaderTitleRow}>{!messageOnly && currentSession?.pinnedAt ? (<Pin@@ -10768,7 +10782,7 @@ function SessionHeaderBar({{notice}</Text>) : null}- </View>+ </Pressable>)}{sharedTaskEnded || systemBack ? null : nativeHeader ? (diff --git a/apps/mobile/src/__tests__/SessionMenuRenameEntry.test.tsx b/apps/mobile/src/__tests__/SessionMenuRenameEntry.test.tsxnew file mode 100644index 0000000000..1c3482a233--- /dev/null+++ b/apps/mobile/src/__tests__/SessionMenuRenameEntry.test.tsx@@ -0,0 +1,194 @@+// @vitest-environment jsdom+vi.mock('@/session/TaskTags', () => ({ TaskTagsPanel: () => null }));+import { act, type ReactNode } from "react";+import { createRoot } from "react-dom/client";+import { expect, it, vi } from "vitest";+import {+ SessionMenuSheet,+ type SessionMenuSheetProps,+} from "@/session/SessionMenuSheet";+import { i18n } from "@/i18n";+import { sharedTaskHostPeer } from '@cindy/device-link';++vi.mock("react-native", async () => {+ const { createElement } = await import("react");+ const view = ({+ children,+ onPress,+ testID,+ }: {+ children?: ReactNode;+ onPress?: () => void;+ testID?: string;+ }) =>+ createElement("div", { onClick: onPress, "data-testid": testID }, children);+ return {+ Platform: { OS: 'android' },+ View: view,+ Pressable: view,+ Text: view,+ TextInput: view,+ ActivityIndicator: () => null,+ Alert: { alert: vi.fn() },+ Animated: {+ Value: class {+ setValue() {}+ },+ View: view,+ timing: () => ({ start: (done?: () => void) => done?.() }),+ },+ StyleSheet: { create: (value: unknown) => value, hairlineWidth: 1 },+ Easing: { bezier: () => (t: number) => t },+ AccessibilityInfo: {+ isReduceMotionEnabled: () => Promise.resolve(false),+ addEventListener: () => ({ remove() {} }),+ },+ useWindowDimensions: () => ({ height: 800, width: 400 }),+ };+});+vi.mock("@/components/AppText", async () => {+ const rn = await import("react-native");+ return { Text: rn.Text, TextInput: rn.TextInput };+});+vi.mock("lucide-react-native", () =>+ Object.fromEntries(+ [+ "Archive",+ "ArchiveRestore",+ "ChevronRight",+ "Copy",+ "Folder",+ "GitBranch",+ "Link2",+ "LogOut",+ "Monitor",+ "Pencil",+ "Pin",+ "PinOff",+ "RefreshCw",+ "Search",+ "Sparkles",+ "Trash2",+ ].map((name) => [name, () => null]),+ ),+);+vi.mock("react-native-safe-area-context", () => ({+ useSafeAreaInsets: () => ({ top: 0, bottom: 0 }),+}));+vi.mock("@/theme", async () => {+ const tokens = await import("@/theme/tokens");+ return {+ ...tokens,+ monoFont: "monospace",+ useTheme: () => ({ colors: tokens.lightColors }),+ useThemedStyles: (make: (colors: typeof tokens.lightColors) => unknown) =>+ make(tokens.lightColors),+ };+});+vi.mock("@/components/MobilePrimitives", async () => {+ const { createElement } = await import("react");+ type Action = { onPress(): void; testID: string };+ return {+ MainWindowActionButton: () => null,+ MainWindowActionGroup: ({ primaryActions, cancelAction }: { primaryActions: Action[]; cancelAction?: Action }) =>+ createElement("div", null, [...primaryActions, ...(cancelAction ? [cancelAction] : [])].map((action) =>+ createElement("button", { key: action.testID, "data-testid": action.testID, onClick: action.onPress }))),+ };+});+vi.mock("@/session/SheetModal", () => ({+ SheetModal: ({ children }: { children: ReactNode }) => children,+}));+vi.mock("@/session/SheetSurface", () => ({+ SheetSurface: ({ children, footer }: { children: ReactNode; footer?: ReactNode }) => <>{children}{footer}</>,+}));+vi.mock("@/session/messageActions", () => ({ writeClipboardText: vi.fn(), formatModelShortLabel: (id: string) => id }));++function baseProps(overrides: Partial<SessionMenuSheetProps> = {}) {+ const reader = {+ getContextUsage: vi.fn(async () => ({ totalTokens: 20, rawMaxTokens: 100 })),+ getCodexRateLimits: vi.fn(),+ getAccountUsage: vi.fn(),+ getSessionEstimatedValue: vi.fn(async () => ({})),+ };+ return {+ usageReader: reader,+ onContextError: vi.fn(),+ onRefreshAccountUsage: vi.fn(),+ onOpenSearch: vi.fn(),+ onRename: vi.fn(),+ onClose: vi.fn(),+ session: { id: "a", model: "custom", providerId: "custom", agentKind: "pi", title: "Task" },+ initialView: "rename",+ visible: true,+ busy: false,+ ...overrides,+ } as unknown as SessionMenuSheetProps;+}++async function renderSheet(props: SessionMenuSheetProps) {+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });+ await i18n.changeLanguage("zh-CN");+ const host = document.createElement("div");+ const root = createRoot(host);+ await act(async () => root.render(<SessionMenuSheet {...props} />));+ const click = async (testID: string) => {+ const node = host.querySelector(`[data-testid="${testID}"]`) as HTMLElement | null;+ if (!node) throw new Error(`missing ${testID}`);+ await act(async () => node.click());+ };+ return { host, root, click };+}++it("opening at rename goes straight to the editor and cancel closes the sheet", async () => {+ const props = baseProps();+ const { host, root, click } = await renderSheet(props);+ try {+ expect(host.querySelector('[data-testid="session.renameBlock"]')).not.toBeNull();+ await click("session.renameCancelButton");+ expect(props.onClose).toHaveBeenCalledOnce();+ expect(props.onRename).not.toHaveBeenCalled();+ } finally {+ await act(async () => root.unmount());+ }+});++it("confirming a direct rename closes the sheet", async () => {+ const props = baseProps();+ const { root, click } = await renderSheet(props);+ try {+ await click("session.renameButton");+ expect(props.onClose).toHaveBeenCalledOnce();+ } finally {+ await act(async () => root.unmount());+ }+});++it("renaming from the menu returns to the menu instead of closing", async () => {+ const props = baseProps({ initialView: "menu" });+ const { host, root, click } = await renderSheet(props);+ try {+ expect(host.querySelector('[data-testid="session.renameBlock"]')).toBeNull();+ await click("session.renameAction");+ expect(host.querySelector('[data-testid="session.renameBlock"]')).not.toBeNull();+ await click("session.renameCancelButton");+ expect(props.onClose).not.toHaveBeenCalled();+ expect(host.querySelector('[data-testid="session.renameBlock"]')).toBeNull();+ } finally {+ await act(async () => root.unmount());+ }+});++it.each([+ ["host-managed", { messageOnly: true }],+ ["worker", { session: { id: "a", title: "Task", orcaRole: "worker" } }],+ ["shared guest", { session: { id: "a", title: "Task", deviceLinkDeviceId: sharedTaskHostPeer("shared", "desktop") } }],+ ["busy", { busy: true }],+] as const)("a %s task does not open the rename editor", async (_name, overrides) => {+ const props = baseProps(overrides as Partial<SessionMenuSheetProps>);+ const { host, root } = await renderSheet(props);+ try {+ expect(host.querySelector('[data-testid="session.renameBlock"]')).toBeNull();+ } finally {+ await act(async () => root.unmount());+ }+});diff --git a/apps/mobile/src/__tests__/useDoubleTap.test.ts b/apps/mobile/src/__tests__/useDoubleTap.test.tsnew file mode 100644index 0000000000..6707b36b44--- /dev/null+++ b/apps/mobile/src/__tests__/useDoubleTap.test.ts@@ -0,0 +1,22 @@+import { describe, expect, it } from 'vitest';+import { DOUBLE_TAP_INTERVAL_MS, registerTap } from '@/session/useDoubleTap';++describe('registerTap', () => {+ it('treats two taps within the interval as a double tap', () => {+ const first = registerTap(null, 1000);+ expect(first.doubleTap).toBe(false);+ expect(registerTap(first.lastTapAt, 1000 + DOUBLE_TAP_INTERVAL_MS).doubleTap).toBe(true);+ });++ it('starts over when the second tap is too late', () => {+ const first = registerTap(null, 1000);+ const late = registerTap(first.lastTapAt, 1001 + DOUBLE_TAP_INTERVAL_MS);+ expect(late).toEqual({ doubleTap: false, lastTapAt: 1001 + DOUBLE_TAP_INTERVAL_MS });+ });++ it('needs two fresh taps after a double tap', () => {+ const second = registerTap(registerTap(null, 1000).lastTapAt, 1100);+ expect(second.doubleTap).toBe(true);+ expect(registerTap(second.lastTapAt, 1200).doubleTap).toBe(false);+ });+});diff --git a/apps/mobile/src/session/SessionDetailsNative.ios.tsx b/apps/mobile/src/session/SessionDetailsNative.ios.tsxindex 466fb02316..9fe0268a20 100644--- a/apps/mobile/src/session/SessionDetailsNative.ios.tsx+++ b/apps/mobile/src/session/SessionDetailsNative.ios.tsx@@ -25,10 +25,11 @@ import {presentationDragIndicator,shapes,} from "@expo/ui/swift-ui/modifiers";-import { ScrollView, View } from "react-native";-import { useState } from "react";+import { ScrollView, useWindowDimensions, View } from "react-native";+import { useCallback, useEffect, useRef, useState } from "react";import { useSafeAreaInsets } from "react-native-safe-area-context";import { radius, spacing, useTheme } from "@/theme";+import { useMobileKeyboardState } from "./useMobileKeyboardState";import type {SessionDetailsAction,SessionDetailsNativeProps,@@ -47,6 +48,7 @@ export function SessionDetailsNative({}: SessionDetailsNativeProps) {const { colors, mode } = useTheme();const { bottom: bottomInset } = useSafeAreaInsets();+ const keyboardOverlap = useKeyboardOverlap(!!footer && visible);return (<HostcolorScheme={mode}@@ -76,7 +78,7 @@ export function SessionDetailsNative({inset inside scroll content, not as an empty strip below its clip. */}<Group modifiers={[padding({ bottom: footer ? 0 : -bottomInset })]}><RNHostView>- <View style={{ flex: 1 }}>+ <View ref={keyboardOverlap.ref} onLayout={keyboardOverlap.measure} style={{ flex: 1 }}><ScrollViewkeyboardShouldPersistTaps="handled"contentContainerStyle={{@@ -88,7 +90,9 @@ export function SessionDetailsNative({{children}</ScrollView>{footer ? (- <View style={{ padding: spacing.lg }}>{footer}</View>+ <View style={{ padding: spacing.lg, paddingBottom: spacing.lg + keyboardOverlap.overlap }}>+ {footer}+ </View>) : null}</View></RNHostView>@@ -100,6 +104,32 @@ export function SessionDetailsNative({);}+/**+ * 底部按钮被键盘挡住的高度。SwiftUI sheet 对内嵌 RN 内容的键盘避让不完整,底部+ * 按钮会被键盘盖住一截;这里按实际位置补齐:量内容区在窗口里的底边,与键盘顶边比较。+ * 量的是外层容器,尺寸不受补出的 padding 影响,不会来回抖动。+ */+function useKeyboardOverlap(enabled: boolean) {+ const ref = useRef<View>(null);+ const keyboard = useMobileKeyboardState();+ const { height: windowHeight } = useWindowDimensions();+ const [bottom, setBottom] = useState<number | null>(null);+ const measure = useCallback(() => {+ ref.current?.measureInWindow((_x, y, _width, height) => setBottom(y + height));+ }, []);+ useEffect(() => {+ if (!enabled || !keyboard.visible) return;+ measure();+ // sheet 跟随键盘移动、展开的动画结束后再量一次,以最终位置为准。+ const timer = setTimeout(measure, 400);+ return () => clearTimeout(timer);+ }, [enabled, keyboard.height, keyboard.visible, measure]);+ const overlap = enabled && keyboard.visible && bottom !== null+ ? Math.max(0, Math.ceil(bottom - (windowHeight - keyboard.height)))+ : 0;+ return { ref, measure, overlap };+}+export function SessionDetailsNativeActions({actions,}: {diff --git a/apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx b/apps/mobile/src/session/SessionHeaderNativeControls.ios.tsxindex 3a7e8e157c..6d70587420 100644--- a/apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx+++ b/apps/mobile/src/session/SessionHeaderNativeControls.ios.tsx@@ -11,10 +11,11 @@ import {VStack,} from "@expo/ui/swift-ui";import { Folder, Monitor, Pin, type LucideIcon } from "lucide-react-native";-import { View } from "react-native";+import { Pressable, View } from "react-native";import { Text } from "@/components/AppText";import { QuietSyncIndicator } from "@/components/QuietSyncIndicator";import { TaskTagDots } from './TaskTags';+import { useDoubleTap } from './useDoubleTap';import {accessibilityHint,accessibilityElement,@@ -94,8 +95,10 @@ export function SessionHeaderNativeBlur({ height: chromeHeight, edge = 'top', inexport function SessionHeaderNativeTitle({ title,tags,onTagsPress,+ onTitleDoubleTap,pinned, syncing, syncingImmediately, notice }: SessionHeaderNativeTitleProps) {const { colors } = useTheme();+ const handleTitlePress = useDoubleTap(onTitleDoubleTap);const style = {alignSelf: 'center' as const,maxWidth: '100%' as const,@@ -123,7 +126,9 @@ export function SessionHeaderNativeTitle({ title,);return (<View style={{ flex: 1, minWidth: 0, justifyContent: 'center' }}>- <View style={style}>+ {/* 双击标题改名;不参与读屏焦点,读屏用户从「任务详情」进入重命名。 */}+ <Pressable accessible={false} disabled={!onTitleDoubleTap} onPress={handleTitlePress}+ style={style} testID="session.titleArea">{/* The title sits directly on the bar: no capsule material behind it. */}<View style={{ flexDirection: "row", minWidth: 0, alignItems: "center", justifyContent: "center", gap: spacing.xs }}>{pinned ? <Pin color={colors.textTertiary} size={iconSize.sm} strokeWidth={iconStroke.regular} /> : null}@@ -142,7 +147,7 @@ export function SessionHeaderNativeTitle({ title,{notice}</Text>) : null}- </View>+ </Pressable></View>);}diff --git a/apps/mobile/src/session/SessionHeaderNativeControls.tsx b/apps/mobile/src/session/SessionHeaderNativeControls.tsxindex 1b0636fb37..a384a0fd36 100644--- a/apps/mobile/src/session/SessionHeaderNativeControls.tsx+++ b/apps/mobile/src/session/SessionHeaderNativeControls.tsx@@ -7,6 +7,8 @@ export interface SessionHeaderNativeBackProps {export interface SessionHeaderNativeTitleProps {onTagsPress?: () => void;+ /** 双击标题:直接打开重命名;不可重命名时不传。 */+ onTitleDoubleTap?: () => void;tags?: import('@cindy/maker-shared').TaskTag[];title: string;pinned: boolean;diff --git a/apps/mobile/src/session/SessionMenuSheet.tsx b/apps/mobile/src/session/SessionMenuSheet.tsxindex 1fedf9c9da..393e4ed11c 100644--- a/apps/mobile/src/session/SessionMenuSheet.tsx+++ b/apps/mobile/src/session/SessionMenuSheet.tsx@@ -81,6 +81,7 @@ import {buildSessionMenuHeader,removeSessionExtraDir,sessionInfoShowsExtraDirs,+ sessionMenuAllowsRename,sessionMenuCopyLink,settleSessionMenuBack,type SessionMenuAction,@@ -223,12 +224,13 @@ export function SessionMenuSheet({const { height: windowHeight } = useWindowDimensions();const insets = useSafeAreaInsets();- const [view, setView] = useState<SessionMenuView>(initialView);+ // 'rename' 只是打开位置(落在一级菜单的重命名编辑态),视图本身仍是 menu / info 两级。+ const [view, setView] = useState<SessionMenuView>(initialView === 'info' ? 'info' : 'menu');const [opening, setOpening] = useState({ visible, initialView });// Reset before effects: reopening the primary menu must not inspect the old info view.if (opening.visible !== visible || opening.initialView !== initialView) {setOpening({ visible, initialView });- if (visible) setView(initialView);+ if (visible) setView(initialView === 'info' ? 'info' : 'menu');}const { contextUsage, contextLoading, refresh: onRefreshContextUsage } = useSessionMenuContextUsage(session, usageReader, visible && !messageOnly && view === 'info', onContextError,@@ -236,6 +238,9 @@ export function SessionMenuSheet({const [primarySnap, setPrimarySnap] = useState<ContextSheetSnap>('half');const [secondarySnap, setSecondarySnap] = useState<ContextSheetSnap>('half');const [renaming, setRenaming] = useState(false);+ // 双击标题直达的重命名:确定 / 取消后直接收起菜单,不退回一级菜单。+ const [renameOnly, setRenameOnly] = useState(false);+ const renameAllowed = sessionMenuAllowsRename(session, messageOnly);const [renameGenerating, setRenameGenerating] = useState(false);const [renameError, setRenameError] = useState<string | null>(null);// 重命名输入框的预填值:哨兵先过投影,输入框里不能出现内部哨兵 "New Maker"@@ -278,20 +283,31 @@ export function SessionMenuSheet({setPrimarySnap('half');setSecondarySnap('half');renameSeqRef.current += 1;- setRenaming(false);+ const startRenaming = initialView === 'rename' && renameAllowed && !busy;+ setRenaming(startRenaming);+ setRenameOnly(startRenaming);+ if (startRenaming) setTitleDraft(renamePrefill);setRenameGenerating(false);setRenameError(null);setCopiedKey(null);setExtraDirsNotice(null);secondaryAnimatingRef.current = false;secondaryTranslate.setValue(initialView === 'info' ? 0 : windowHeightRef.current);+ // 只在打开时决定落点;打开期间 busy / 标题变化不重跑整段重置。+ // eslint-disable-next-line react-hooks/exhaustive-deps}, [visible, initialView, secondaryTranslate]);- // 会话切换 / 远端改名后同步标题草稿,并退出编辑态。+ // 会话切换 / 远端改名后同步标题草稿,并退出编辑态。首次挂载跳过:浮窗由+ // MountOnFirstOpen 首开即挂载,此时上面的打开重置可能刚进入重命名编辑态。+ const renameSourceRef = useRef({ id: session.id, prefill: renamePrefill });useEffect(() => {+ const source = renameSourceRef.current;+ if (source.id === session.id && source.prefill === renamePrefill) return;+ renameSourceRef.current = { id: session.id, prefill: renamePrefill };renameSeqRef.current += 1;setTitleDraft(renamePrefill);setRenaming(false);+ setRenameOnly(false);setRenameGenerating(false);setRenameError(null);}, [session.id, renamePrefill]);@@ -393,6 +409,7 @@ export function SessionMenuSheet({setRenaming(false);setRenameGenerating(false);setRenameError(null);+ if (renameOnly) onClose();// 「没改就不落库」要同时比原始标题**和**预填的投影值:未起名会话预填的是本地化// 兜底文案,只比原始标题会把这个文案写进 DB,哨兵被毁 → 自动起名永久跳过该会话。if (!next || next === session.title || next === renamePrefill) {@@ -400,7 +417,7 @@ export function SessionMenuSheet({return;}onRename(next);- }, [onRename, renamePrefill, session.title, titleDraft]);+ }, [onClose, onRename, renameOnly, renamePrefill, session.title, titleDraft]);const cancelRename = useCallback(() => {renameSeqRef.current += 1;@@ -408,7 +425,8 @@ export function SessionMenuSheet({setRenameGenerating(false);setRenameError(null);setTitleDraft(renamePrefill);- }, [renamePrefill]);+ if (renameOnly) onClose();+ }, [onClose, renameOnly, renamePrefill]);// 自动起名:生成结果只回填输入框,停留在编辑态等用户按「确定」提交(2026-07-06// 产品确认,与桌面「生成即提交」刻意不同);生成期间用户手动提交 / 取消 →diff --git a/apps/mobile/src/session/sessionMenu.ts b/apps/mobile/src/session/sessionMenu.tsindex 2155046ff0..6ab29afd3e 100644--- a/apps/mobile/src/session/sessionMenu.ts+++ b/apps/mobile/src/session/sessionMenu.ts@@ -5,6 +5,7 @@* 置顶 / 归档 / 删除)+「会话信息」二级入口;二级 = 用量 / 工作目录 / 附加引用目录 / 标识。* 全部为纯函数,不碰 IO;交互副作用(clipboard / Alert / 远端写)由组件层承担。*/+import { isSharedTaskPeer } from '@cindy/device-link';import { isDefaultDraftSessionTitle } from '@cindy/maker-shared/session-title';import { i18n } from '@/i18n';@@ -15,8 +16,19 @@ import { sessionWorktreeInfo } from '@/session/sessionWorktree';import type { RemoteSession } from '@/session/types';import { formatRemoteMoney, resolveSessionTotalMoney } from '@/session/remoteMoney';-/** 菜单 sheet 的两级视图:一级操作菜单 / 二级会话信息。 */-export type SessionMenuView = 'menu' | 'info';+/**+ * 菜单 sheet 的打开位置:一级操作菜单 / 二级会话信息 / 直接进入重命名编辑态+ * (双击任务标题的入口;确定或取消后直接收起菜单)。+ */+export type SessionMenuView = 'menu' | 'info' | 'rename';++/** 菜单里是否提供重命名:Host 托管、协同 Worker、共享任务访客都不提供。 */+export function sessionMenuAllowsRename(+ session: Pick<RemoteSession, 'deviceLinkDeviceId' | 'orcaRole'>,+ messageOnly: boolean,+): boolean {+ return !messageOnly && session.orcaRole !== 'worker' && !isSharedTaskPeer(session.deviceLinkDeviceId ?? '');+}export interface SessionMenuChip {id: 'pinned' | 'archived' | 'collab';diff --git a/apps/mobile/src/session/useDoubleTap.ts b/apps/mobile/src/session/useDoubleTap.tsnew file mode 100644index 0000000000..ec0f84bd73--- /dev/null+++ b/apps/mobile/src/session/useDoubleTap.ts@@ -0,0 +1,27 @@+import { useCallback, useRef } from 'react';++/** 两次点按的最大间隔(与 iOS 系统双击判定同量级)。 */+export const DOUBLE_TAP_INTERVAL_MS = 300;++/**+ * 判断本次点按是否与上一次构成双击。构成双击后清空记录,第三下重新开始计数。+ * 纯函数便于测试;组件层用 useDoubleTap。+ */+export function registerTap(lastTapAt: number | null, now: number): { doubleTap: boolean; lastTapAt: number | null } {+ if (lastTapAt !== null && now - lastTapAt <= DOUBLE_TAP_INTERVAL_MS) {+ return { doubleTap: true, lastTapAt: null };+ }+ return { doubleTap: false, lastTapAt: now };+}++/** 返回点按处理函数:两次点按间隔不超过 DOUBLE_TAP_INTERVAL_MS 时调用 onDoubleTap。 */+export function useDoubleTap(onDoubleTap: (() => void) | undefined): () => void {+ const lastTapAt = useRef<number | null>(null);+ const callback = useRef(onDoubleTap);+ callback.current = onDoubleTap;+ return useCallback(() => {+ const result = registerTap(lastTapAt.current, Date.now());+ lastTapAt.current = result.lastTapAt;+ if (result.doubleTap) callback.current?.();+ }, []);+}