Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): Android 伙伴私聊气泡里的点按被长按菜单吞掉
zqchris0807e842b1b5
diff --git a/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx b/apps/mobile/src/__tests__/androidMaterialMenu.test.tsxindex 2e9a98d1bc..0b0d2a5dc7 100644--- a/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx+++ b/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx@@ -291,3 +291,33 @@ it.each(["light", "dark"])().toBe(mode);},);+// Companion bubbles: the caller opens the menu on its own long press, so the content+// (quote, links, tables) must keep its taps instead of sitting under pointer-events none.+it("keeps the content interactive when the caller controls opening", () => {+ const choose = vi.fn();+ const openChange = vi.fn();+ const contentPress = vi.fn();+ const render = (open: boolean) =>+ act(() =>+ root.render(+ <AnchoredPullDownMenu+ actions={[{ id: "reply", title: "Reply" }]}+ onAction={choose}+ onOpenChange={openChange}+ open={open}+ >+ <button onClick={contentPress}>Quote</button>+ </AnchoredPullDownMenu>,+ ),+ );+ render(false);+ const content = Array.from(container.querySelectorAll("button")).find((b) => b.textContent === "Quote");+ expect(content?.closest('[data-pointer-events="none"]')).toBeNull();+ click("Quote");+ expect(contentPress).toHaveBeenCalledTimes(1);+ expect(container.querySelector("section")).toBeNull();+ render(true);+ click("Reply");+ expect(choose).toHaveBeenCalledWith("reply");+ expect(openChange).toHaveBeenLastCalledWith(false);+});diff --git a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsxindex af2fc6a8d3..f4256c53a0 100644--- a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx+++ b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx@@ -14,7 +14,7 @@ import {width,testID as nativeTestID,} from "@expo/ui/jetpack-compose/modifiers";-import { Fragment, isValidElement, useState, type ComponentProps } from "react";+import { Fragment, isValidElement, useEffect, useState, type ComponentProps } from "react";import {Pressable,StyleSheet,@@ -138,14 +138,27 @@ export function AnchoredPullDownMenu({style,testID,accessibilityLabel,+ open: controlledOpen,+ onOpenChange,}: ComponentProps<typeof CompatibleMenu>) {const { colors, mode } = useTheme();- const [open, setOpen] = useState(false);+ const controlled = controlledOpen !== undefined;+ const [uncontrolledOpen, setUncontrolledOpen] = useState(false);+ const open = controlled ? controlledOpen : uncontrolledOpen;+ const setOpen = (next: boolean) => {+ if (controlled) onOpenChange?.(next);+ else setUncontrolledOpen(next);+ };// Lazily create the Compose tree, then reuse it for this trigger's lifetime.// Removing it on every close adds Fabric mount work to the next input frame// and cuts off Material's exit animation. The popup itself still closes.const [mounted, setMounted] = useState(false);const [path, setPath] = useState<string[]>([]);+ useEffect(() => {+ if (!controlled || !controlledOpen) return;+ setMounted(true);+ setPath([]);+ }, [controlled, controlledOpen]);const child = isValidElement(children)? (children.props as AccessibilityProps): {};@@ -168,6 +181,10 @@ export function AnchoredPullDownMenu({};return (<View style={style}>+ {controlled ? (+ // The caller opens the menu (e.g. on its own long press); the content keeps its own touches.+ <View collapsable={false} testID={testID}>{children}</View>+ ) : (<PressableaccessibilityLabel={accessibilityLabel ?? child.accessibilityLabel}accessibilityHint={child.accessibilityHint}@@ -185,7 +202,8 @@ export function AnchoredPullDownMenu({{children}</View></Pressable>- {mounted ? (+ )}+ {mounted || (controlled && open) ? (// The anchor has no input of its own. RN must exclude the Host from// hit testing; Compose's popup receives input in its separate window.<View pointerEvents="none" style={StyleSheet.absoluteFill}>diff --git a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsxindex 4434efd111..e6f7fcd601 100644--- a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx+++ b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx@@ -98,6 +98,8 @@ export function AnchoredPullDownMenu({onPress,style,testID,+ open: controlledOpen,+ onOpenChange,}: {accessibilityLabel?: string;actions: readonly NativePullDownAction[];@@ -109,12 +111,19 @@ export function AnchoredPullDownMenu({/** 触发器在父布局里的样式(如 flex: 1);外层替子元素占据父布局里的位置。 */style?: StyleProp<ViewStyle>;testID?: string;+ /**+ * 由调用方控制打开(例如它自己识别长按)。传入后不再接管触摸:子元素里的链接、+ * 横向滚动照常可用,菜单仍贴着这块内容弹出;关闭时回调 onOpenChange(false)。+ */+ open?: boolean;+ onOpenChange?(open: boolean): void;}) {const styles = useThemedStyles(makeStyles);const anchorRef = useRef<View>(null);const [anchor, setAnchor] = useState<Anchor | null>(null);const [path, setPath] = useState<string[]>([]);const open = anchor !== null;+ const controlled = controlledOpen !== undefined;const show = useCallback(() => {const node = anchorRef.current;@@ -124,11 +133,22 @@ export function AnchoredPullDownMenu({setAnchor({ x, y, width, height });});}, []);- const close = useCallback(() => setAnchor(null), []);+ const close = useCallback(() => {+ setAnchor(null);+ onOpenChange?.(false);+ }, [onOpenChange]);+ useEffect(() => {+ if (!controlled) return;+ if (controlledOpen) show();+ else setAnchor(null);+ }, [controlled, controlledOpen, show]);const child = childAccessibility(children);return (<>+ {controlled ? (+ <View ref={anchorRef} collapsable={false} style={style} testID={testID}>{children}</View>+ ) : (<Pressableref={anchorRef}accessibilityHint={child.accessibilityHint}@@ -151,6 +171,7 @@ export function AnchoredPullDownMenu({{children}</View></Pressable>+ )}{open ? (<AnchoredMenuOverlayactions={actions}diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsxindex 111288f637..f8e3a5ce81 100644--- a/apps/mobile/src/session/MessageRenderer.tsx+++ b/apps/mobile/src/session/MessageRenderer.tsx@@ -19,6 +19,7 @@ import { BotGroupQuote } from './BotGroupQuote';import { companionReplyQuoteDisplay, companionReplyQuoteFor } from './companionReplyQuote';import type { ChatReplyQuote } from '@cindy/maker-shared/chat-reply-quote';import type { NativePullDownAction } from '@/platform/chrome/NativePullDownMenu';+import { AnchoredPullDownMenu } from '@/platform/chrome/AnchoredPullDownMenu';import { Gesture, GestureDetector } from '@/platform/gestureHandler';import { useMessageHistoryActive, useMessageHistoryPositioning } from './messageHistoryActivity';import { usePaneViewport } from '@/platform/AdaptiveWindowContext';@@ -3694,7 +3695,8 @@ function MessageBubble({const disabled = !!actions.busyClientId;// 伙伴私聊:长按消息弹出系统菜单(对应桌面悬停时的「回复」等按钮),消息下方不再常驻图标。// iOS 用系统操作表(MenuView 的长按预览在新架构下抬不起气泡,不改原生代码时不用它);- // Android 用平台下拉菜单。都不可用时退回原来的操作行。长按交给菜单后正文不再就地选字,改由「选择文字」打开。+ // Android 由同一个长按手势打开贴着气泡的下拉菜单(菜单不包住气泡,气泡里的点按照常可用)。+ // 都不可用时退回原来的操作行。长按交给菜单后正文不再就地选字,改由「选择文字」打开。const companionQuote = actions.companionQuoteActions;const companionMenuEnabled = !!(actions.companion && hasActions&& (Platform.OS === 'ios' ? usesSystemActionMenu() : usesNativePullDownMenu()));@@ -3809,9 +3811,14 @@ function MessageBubble({userInterfaceStyle: mode,}).then(result => { if (result.kind === 'action') selectCompanionMenuAction(result.key); });}, [absoluteTime, companionMenuActions, mode, selectCompanionMenuAction, t]);+ // Android's anchored menu opens here rather than wrapping the bubble, which would swallow its taps.+ const [companionMenuOpen, setCompanionMenuOpen] = useRecyclingState(false);// Long press fails as soon as the finger moves, so tables and code blocks keep scrolling sideways.const companionMenuGesture = useMemo(() => Gesture.LongPress().minDuration(450).runOnJS(true)- .onStart(() => openCompanionActionSheet()), [openCompanionActionSheet]);+ .onStart(() => {+ if (Platform.OS === 'ios') openCompanionActionSheet();+ else setCompanionMenuOpen(true);+ }), [openCompanionActionSheet, setCompanionMenuOpen]);const openMessageActionMenu = useCallback(() => {if (usesSystemActionMenu()) {const disabled = actionBusy@@ -4138,19 +4145,18 @@ function MessageBubble({{item.message.rawError ? <AgentErrorDetails key={item.message.key} message={item.message.rawError} /> : null}</ErrorNotice>) : bubbleShown ? (- companionMenuEnabled ? (Platform.OS === 'ios' ? (+ companionMenuEnabled ? (<GestureDetector gesture={companionMenuGesture}><View style={isUser ? styles.companionMenuUser : styles.companionMenuAgent} testID="companion.messageMenu">- {bubble}+ {Platform.OS === 'ios' ? bubble : (+ <AnchoredPullDownMenu actions={companionMenuActions} onAction={selectCompanionMenuAction}+ open={companionMenuOpen} onOpenChange={setCompanionMenuOpen}>+ {bubble}+ </AnchoredPullDownMenu>+ )}</View></GestureDetector>- ) : (- <NativePullDownMenu longPress actions={companionMenuActions}- onAction={selectCompanionMenuAction} style={isUser ? styles.companionMenuUser : styles.companionMenuAgent}- testID="companion.messageMenu">- {bubble}- </NativePullDownMenu>- )) : bubble+ ) : bubble) : null}{actions.companion && item.message.kind === 'assistant' && item.message.body.trim() ? (<CompanionLearningFooter receipts={item.message.source.agentMeta?.botLearning}diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.mdindex 6da51533dd..35cb897f6c 100644--- a/docs/product-rules/cindy-bots-runtime.md+++ b/docs/product-rules/cindy-bots-runtime.md@@ -91,8 +91,8 @@ Chris:「私聊话题和群聊话题,要真的能把独立事件隔离到独消息上(只进发给模型的内容,不进落库原话,逐条附带;渲染端的摘要不进入模型);声明它只是背景、不构成指令;原消息只有附件没有文字时列出附件名,已回滚或不存在时才如实说不可用。普通发送与回复过程中的插话都附带。伙伴回复的引用块与摘要按用户看到的文字(组件内容转成可读文字),不显示组件源码。-- **手机端(2026-10-22)**:长按私聊气泡打开消息菜单(iOS 为系统操作表,标题是准确时间;Android 为原生长按菜单),- 依次是回复、复制、选择文字、分享,以及原有的消息链接、回到这里与删除。长按只用 RNGH LongPress(450ms,手指一动+- **手机端(2026-10-22)**:长按私聊气泡打开消息菜单(iOS 为系统操作表,标题是准确时间;Android 为贴着气泡弹出的下拉菜单,菜单不包住气泡,气泡里的引用、链接与横向滚动照常可点),+ 依次是回复、复制、选择文字、分享,以及原有的消息链接、回到这里与删除。两端长按都只用 RNGH LongPress(450ms,手指一动即失败),表格和代码块照旧横向滚动;因此私聊气泡正文不再就地选择,改由「选择文字」面板做部分选择(iOS 用UITextView,去掉 Markdown 记号,代码块与行内代码保持原文)。回复在输入框上方放同一种待发引用(卡片底色,× 取消),随普通发送、离线发件箱与排队编辑一起保留在信封 `replyQuote` 里;待发、已发气泡顶部都显示引用块(只发附件时也显示),点击定位原消息;没有正文气泡的消息(纯附件、错误)保留原操作行。信封解析与摘要和