Skip to content

armgit / cindy

Public Imported from GitHub
0

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

fix(mobile): 恢复伙伴聊天直接选字并精简消息菜单

Dash9edce9edce95
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index c164bb3e14..cbcda30806 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -183,7 +183,6 @@ import {
type MobileMessageDraft,
} from '@/session/MessageRenderer';
import { BotGroupQuote } from '@/session/BotGroupQuote';
-import { CompanionSelectTextSheet } from '@/session/CompanionSelectTextSheet';
import {
clearSentCompanionReplyQuote,
companionReplyQuoteDisplay,
@@ -6208,8 +6207,6 @@ function SessionScreenContent({ beforeSessionSwitchRef, newSessionActionRef }: S
const showCompanionReplyTargets = useCompanionReplyTargetPreference();
const pendingCompanionReplyQuote = usePendingCompanionReplyQuote(companionChat ? sessionId : null);
const companionQuoteNames = useMemo(() => ({ owner: t('message.renderer.you'), companion: companionName }), [companionName, t]);
- const [companionSelectText, setCompanionSelectText] = useState<string | null>(null);
- useEffect(() => setCompanionSelectText(null), [sessionId]);
const companionQuoteOptions = useMemo<CompanionQuoteOptions | undefined>(() => (companionChat && sessionId ? {
names: companionQuoteNames,
showReplyTargets: showCompanionReplyTargets,
@@ -6218,7 +6215,6 @@ function SessionScreenContent({ beforeSessionSwitchRef, newSessionActionRef }: S
requestAnimationFrame(() => composerInputRef.current?.focus());
},
onLocate: (clientId) => router.setParams({ focusClientId: clientId, focusRequestKey: String(Date.now()) }),
- onSelectText: (text) => setCompanionSelectText(text),
} : undefined), [companionChat, companionQuoteNames, router, sessionId, showCompanionReplyTargets]);
const pendingCompanionQuoteOriginal = useMemo(() => {
const clientId = pendingCompanionReplyQuote?.clientId;
@@ -9992,10 +9988,6 @@ function SessionScreenContent({ beforeSessionSwitchRef, newSessionActionRef }: S
/>
) : null
)}</MountOnFirstOpen>
- {companionSelectText !== null ? (
- <CompanionSelectTextSheet key={`select-text:${deviceId}:${sessionId}`} text={companionSelectText}
- onClose={() => setCompanionSelectText(null)} />
- ) : null}
{currentSession ? <SideChatsSheet key={`${deviceId}:${sessionId}`} visible={sideChatsOpen}
session={currentSession} maker={maker} onClose={() => setSideChatsOpen(false)}
onCreate={() => createSideChat()} onSelect={openSideChat} /> : null}
diff --git a/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts b/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts
index 5a9e131915..2cd7dcbefa 100644
--- a/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts
+++ b/apps/mobile/src/__tests__/messageNativeLifecycleContracts.test.ts
@@ -299,10 +299,9 @@ it('renders message bodies natively with in-place per-block selectable text', ()
const markdownBodyEnd = source.indexOf('function renderInline', markdownBodyStart);
const markdownBodySource = source.slice(markdownBodyStart, markdownBodyEnd);
- // 完成态才可选中;正文与 secondaryBody 都走原生 selectable。伙伴私聊的长按交给系统菜单,
- // 正文改由菜单里的「选择文字」选取,其余任务照旧就地选择。
+ // 完成态才可选中;伙伴与普通任务的正文和 secondaryBody 都走原生 selectable。
expect(source).toContain('const canSelectVisibleText = canUseCompletedActions && copyText.trim().length > 0;');
- expect(source).toContain('const bubbleTextSelectable = canSelectVisibleText && !companionMenuEnabled;');
+ expect(source).toContain('const bubbleTextSelectable = canSelectVisibleText;');
expect(bubbleSource).toContain('selectable={bubbleTextSelectable}');
expect(bubbleSource).toContain('<MarkdownSelectableText selectable={bubbleTextSelectable} style={styles.detailText}>');
@@ -317,11 +316,10 @@ it('renders message bodies natively with in-place per-block selectable text', ()
expect(source).toContain('const SpanText = ctx.SpanText ?? MessageBodyText;');
expect(markdownBodySource).toContain('blockSelectable && allowIosUITextView && Platform.OS === \'ios\'');
- // 气泡是纯 View,不挂 Pressable/onLongPress(避免干扰横向 ScrollView 手势)。伙伴私聊的长按
- // 只用 RNGH LongPress:手指一移动就失败,表格与代码块照旧横向滚动。
+ // 气泡不抢占正文的原生选字或表格、代码块横向滚动手势。
expect(bubbleSource).not.toContain('<Pressable');
expect(bubbleSource).not.toContain('onLongPress');
- expect(bubbleSource).toContain('Gesture.LongPress().minDuration(450).runOnJS(true)');
+ expect(bubbleSource).not.toContain('<GestureDetector');
// 列表内正文只有原生渲染路径:无选择 WebView、无全屏选择查看器。
expect(markdownBodySource).toContain('testID="message.markdownBody"');
diff --git a/apps/mobile/src/__tests__/messageSourceLabelsRender.test.tsx b/apps/mobile/src/__tests__/messageSourceLabelsRender.test.tsx
index 9faa04a3a5..ad0eb49bcd 100644
--- a/apps/mobile/src/__tests__/messageSourceLabelsRender.test.tsx
+++ b/apps/mobile/src/__tests__/messageSourceLabelsRender.test.tsx
@@ -25,11 +25,12 @@ const viewportHarness = vi.hoisted(() => ({
vi.mock("react-native", async () => {
const React = await import("react");
// onLongPress 映射到 contextmenu,便于测试长按显示来源 ID。
- const view = ({ children, testID, accessibilityLabel, accessibilityHint, onLongPress, onPress, disabled }: any) =>
+ const view = ({ children, testID, accessibilityLabel, accessibilityHint, onLongPress, onPress, disabled, selectable }: any) =>
React.createElement(
"div",
{
"data-testid": testID,
+ ...(selectable !== undefined ? { "data-selectable": String(selectable) } : {}),
"aria-label": accessibilityLabel,
...(accessibilityHint ? { "data-hint": accessibilityHint } : {}),
...(onLongPress ? { onContextMenu: () => onLongPress() } : {}),
@@ -232,9 +233,6 @@ vi.mock("@/session/mathWebView", () => ({ MathFormulaWebView: () => null }));
vi.mock("@/session/mediaPlayerWebView", () => ({
RemoteMediaPlayerWebView: () => null,
}));
-vi.mock("@/session/MarkdownBlockContent", () => ({
- MarkdownBlockContent: () => null,
-}));
// 只把菜单项 id 投到 DOM,供删除入口可见性断言;不渲染真实底部面板。
vi.mock("@/session/MessageActionSheet", () => ({
MessageActionSheet: ({ items }: any) =>
@@ -599,29 +597,28 @@ describe('private group reply source', () => {
});
});
-// VoiceOver / TalkBack cannot perform the bubble's long-press gesture, so the companion menu
-// falls back to the action row, whose Reply quotes the message like the menu does.
-describe("companion menu with a screen reader", () => {
- it("keeps the action row and quotes on Reply while a screen reader is on", () => {
+// Regression: the companion menu disabled native text selection (2026-10-25 user decision).
+// Render the real MessageRenderer with one completed reply and system menus available;
+// verify native selectable text and a working Reply action coexist (unit tier).
+describe("companion text selection and actions", () => {
+ it.each(["user", "assistant"] as const)("keeps %s text selectable alongside Reply when system menus are available", (role) => {
a11y.systemMenu = true;
const onQuote = vi.fn();
const props = {
companion: true,
- companionQuote: { names: { owner: "你", companion: "Vela" }, showReplyTargets: false, onQuote, onLocate: vi.fn(), onSelectText: vi.fn() },
+ companionQuote: { names: { owner: "你", companion: "Vela" }, showReplyTargets: false, onQuote, onLocate: vi.fn() },
onAddMessageToComposer: vi.fn(),
};
- const h = mount([{ ...msg("r1", "Done", { turnCompleted: true }), role: "assistant" }], props);
+ const h = mount([{ ...msg("r1", "Done", { turnCompleted: true }), role }], props);
try {
- expect(h.host.querySelector('[data-testid="companion.messageMenu"]')).not.toBeNull();
- expect(h.host.querySelector('[data-testid="companion.messageActions"]')).toBeNull();
- act(() => a11y.screenReader?.(true));
- expect(h.host.querySelector('[data-testid="companion.messageMenu"]')).toBeNull();
+ const body = h.host.querySelector(`[data-testid="message.${role === "user" ? "user" : "agent"}Bubble"]`)!;
+ expect(body.querySelector('[data-selectable="true"]')?.textContent).toBe("Done");
+ expect(h.host.querySelector('[data-testid="companion.messageActions"]')).not.toBeNull();
const reply = h.host.querySelector('[data-testid="companion.messageReply"]')!;
act(() => reply.dispatchEvent(new MouseEvent("click", { bubbles: true })));
- expect(onQuote).toHaveBeenCalledExactlyOnceWith({ clientId: "r1", role: "assistant", excerpt: "Done" });
+ expect(onQuote).toHaveBeenCalledExactlyOnceWith({ clientId: "r1", role, excerpt: "Done" });
expect(props.onAddMessageToComposer).not.toHaveBeenCalled();
} finally {
- act(() => a11y.screenReader?.(false));
a11y.systemMenu = false;
h.unmount();
}
@@ -632,7 +629,7 @@ describe("companion menu with a screen reader", () => {
const onAddMessageToComposer = vi.fn();
const h = mount([{ ...msg("e1", "Boom", { turnCompleted: true }), role: "error" }], {
companion: true,
- companionQuote: { names: { owner: "你", companion: "Vela" }, showReplyTargets: false, onQuote, onLocate: vi.fn(), onSelectText: vi.fn() },
+ companionQuote: { names: { owner: "你", companion: "Vela" }, showReplyTargets: false, onQuote, onLocate: vi.fn() },
onAddMessageToComposer,
});
try {
diff --git a/apps/mobile/src/__tests__/selectableMessageText.test.ts b/apps/mobile/src/__tests__/selectableMessageText.test.ts
deleted file mode 100644
index 9a1b3fc93a..0000000000
--- a/apps/mobile/src/__tests__/selectableMessageText.test.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-// Unit tier: the 「选择文字」 sheet copies what this returns, so code must come out exactly as shown.
-import { describe, expect, it } from 'vitest';
-import { selectableMessageText } from '@/session/selectableMessageText';
-
-describe('selectableMessageText', () => {
- it('drops Markdown marks from prose', () => {
- expect(selectableMessageText('## Title\n- **bold** and [link](https://x.y)')).toBe('Title\n• bold and link');
- });
-
- it('keeps fenced and inline code verbatim', () => {
- const markdown = 'Run `print("**value**")` first.\n```python\n# important\nx = "**value**"\n```';
- expect(selectableMessageText(markdown)).toBe('Run print("**value**") first.\n# important\nx = "**value**"');
- });
-});
diff --git a/apps/mobile/src/session/CompanionSelectTextSheet.tsx b/apps/mobile/src/session/CompanionSelectTextSheet.tsx
deleted file mode 100644
index c0a3cb24d6..0000000000
--- a/apps/mobile/src/session/CompanionSelectTextSheet.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * 伙伴私聊长按菜单的「选择文字」:长按交给系统菜单后,正文改在这里用系统文字选择挑一部分复制。
- * 挂载即打开;关闭先播完系统收起,再由 onClose 卸载,不叠第二个面板。iOS 用 UITextView,可只选一部分。
- * Android 用按内容定高的面板:短消息不留大片空白,长消息在面板内滚动。不用原生底部面板:它打开时把
- * 焦点交给可选文字,Android 会在正文上画一条默认焦点高亮。
- */
-import { useState } from 'react';
-import { Platform, ScrollView, StyleSheet, View } from 'react-native';
-import { UITextView } from 'react-native-uitextview';
-import { useTranslation } from 'react-i18next';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { Text } from '@/components/AppText';
-import { usePaneViewport } from '@/platform/AdaptiveWindowContext';
-import { radius, useThemedStyles, type ThemeColors } from '@/theme';
-import { fontWeight, lineHeight, spacing, typeScale } from '@/theme/tokens';
-import { CompanionSheet } from './CompanionSheet';
-import { SheetModal } from './SheetModal';
-import { SheetGrabber } from './SheetSurface';
-import { selectableMessageText } from './selectableMessageText';
-
-export function CompanionSelectTextSheet({ text, onClose }: { text: string; onClose: () => void }) {
- const { t } = useTranslation();
- const styles = useThemedStyles(makeStyles);
- const insets = useSafeAreaInsets();
- // The pane SheetModal lays this out in (one side of a fold, a floating panel), not the whole window.
- const viewport = usePaneViewport();
- const [visible, setVisible] = useState(true);
- const title = t('message.renderer.selectText');
- const close = () => setVisible(false);
- if (Platform.OS === 'android') {
- return (
- <SheetModal visible={visible} onRequestClose={close} onBackdropPress={close} onClosed={onClose}>
- <View style={[styles.androidCard, { maxHeight: viewport.height * 0.8, paddingBottom: spacing.lg + insets.bottom }]}
- testID="companion.selectTextSheet">
- <SheetGrabber />
- <Text accessibilityRole="header" numberOfLines={1} style={styles.title}>{title}</Text>
- {/* Sized by its text inside the content-height sheet; scrolls once it reaches the cap. */}
- <ScrollView style={styles.scroll}>
- <Text selectable style={styles.text}>{selectableMessageText(text)}</Text>
- </ScrollView>
- </View>
- </SheetModal>
- );
- }
- return (
- <CompanionSheet visible={visible} title={title} onClose={close} onClosed={onClose} testID="companion.selectTextSheet">
- <View style={styles.content}>
- {/* iOS RN Text can only copy the whole block; UITextView gives system handles for part of it. */}
- <UITextView selectable uiTextView style={styles.text}>{selectableMessageText(text)}</UITextView>
- </View>
- </CompanionSheet>
- );
-}
-
-const makeStyles = (colors: ThemeColors) => StyleSheet.create({
- content: { paddingBottom: spacing.lg },
- // Same surface, corners and padding as the other teammate sheets (SheetSurface).
- androidCard: {
- backgroundColor: colors.surfaceElevated,
- borderTopLeftRadius: radius.container,
- borderTopRightRadius: radius.container,
- paddingHorizontal: 20,
- paddingTop: spacing.sm,
- },
- scroll: { flexGrow: 0 },
- title: { color: colors.textPrimary, fontSize: typeScale.body, lineHeight: lineHeight.body, fontWeight: fontWeight.semibold, textAlign: 'center', paddingBottom: spacing.md },
- text: { color: colors.textPrimary, fontSize: typeScale.bodyLarge, lineHeight: lineHeight.bodyLarge },
-});
diff --git a/apps/mobile/src/session/MessageRenderer.tsx b/apps/mobile/src/session/MessageRenderer.tsx
index af4ac27319..7e92774841 100644
--- a/apps/mobile/src/session/MessageRenderer.tsx
+++ b/apps/mobile/src/session/MessageRenderer.tsx
@@ -18,10 +18,6 @@ import { CompanionMessageActions } from './CompanionMessageActions';
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 { useScreenReaderEnabled } from '@/hooks/useScreenReaderEnabled';
import { useMessageHistoryActive, useMessageHistoryPositioning } from './messageHistoryActivity';
import { usePaneViewport } from '@/platform/AdaptiveWindowContext';
import { messageReadingPosition } from './messageReadingPosition';
@@ -665,8 +661,6 @@ export interface CompanionQuoteOptions {
onQuote: (quote: ChatReplyQuote) => void;
/** Scroll to and highlight a message of this chat, loading it first when needed. */
onLocate: (clientId: string) => void;
- /** 「选择文字」: the page shows this message's text where the system text selection works. */
- onSelectText: (text: string) => void;
}
interface CompanionQuoteActions extends CompanionQuoteOptions {
@@ -680,8 +674,6 @@ interface MessageActions {
onRetryImageDelivery?: (imageId: string) => Promise<void>;
companion?: boolean;
companionQuoteActions?: CompanionQuoteActions;
- /** VoiceOver / TalkBack on: the long-press menu has no screen-reader entry, keep the action row. */
- screenReaderEnabled?: boolean;
onCompanionReadThrough?: (at: number) => void;
onOpenCompanionSettings?: (page: 'memory' | 'capabilities') => void;
companionWorkingLabel?: string | null;
@@ -1827,11 +1819,9 @@ export function MessageRenderer({
isLastReplyFor: (assistantClientId) => lastReplies.has(assistantClientId),
};
}, [companion, companionQuote, lastCompanionReplyKey]);
- const screenReaderEnabled = useScreenReaderEnabled();
const actions: MessageActions & { firstUserMessageClientId?: string } = useMemo(() => ({
companion,
companionQuoteActions,
- screenReaderEnabled,
companionWorkingLabel,
onOpenCompanionSettings,
companionAvatar,
@@ -1875,7 +1865,6 @@ export function MessageRenderer({
}), [
companion,
companionQuoteActions,
- screenReaderEnabled,
companionWorkingLabel,
onOpenCompanionSettings,
companionAvatar,
@@ -3698,15 +3687,9 @@ function MessageBubble({
const actionBusy = !!clientId && actions.busyClientId === clientId;
const forkBusy = actionBusy && actions.busyAction === 'fork';
const disabled = !!actions.busyClientId;
- // 伙伴私聊:长按消息弹出系统菜单(对应桌面悬停时的「回复」等按钮),消息下方不再常驻图标。
- // iOS 用系统操作表(MenuView 的长按预览在新架构下抬不起气泡,不改原生代码时不用它);
- // Android 由同一个长按手势打开贴着气泡的下拉菜单(菜单不包住气泡,气泡里的点按照常可用)。
- // 都不可用、或开着读屏(长按手势没有读屏入口)时退回原来的操作行,其中「回复」同样放引用。
- // 长按交给菜单后正文不再就地选字,改由「选择文字」打开。
+ // 伙伴与普通任务都保留正文原生长按选字;消息操作由气泡下方按钮承接。
const companionQuote = actions.companionQuoteActions;
- const companionMenuEnabled = !!(actions.companion && hasActions && !actions.screenReaderEnabled
- && (Platform.OS === 'ios' ? usesSystemActionMenu() : usesNativePullDownMenu()));
- const bubbleTextSelectable = canSelectVisibleText && !companionMenuEnabled;
+ const bubbleTextSelectable = canSelectVisibleText;
const replyQuote = companionQuote && item.message.kind === 'user' ? item.message.replyQuote : undefined;
const replyTargetId = companionQuote?.showReplyTargets && item.message.kind === 'assistant' && clientId
? readReplyToClientId(item.message) : null;
@@ -3714,23 +3697,6 @@ function MessageBubble({
const replyTarget = replyTargetId && isOwnerTypedMessage(replyTargetMessage)
&& companionQuote?.isLastReplyFor(clientId)
? companionReplyQuoteFor(replyTargetMessage) : null;
- const companionMenuActions = useMemo<NativePullDownAction[]>(() => {
- if (!companionMenuEnabled) return [];
- const quick: NativePullDownAction[] = [
- ...(companionQuote && canAddToChat ? [{ id: 'reply', title: t('message.renderer.reply'), image: 'bubble.left' }] : []),
- ...(canCopy ? [{ id: 'copy', title: t('message.renderer.copyStateCopy'), image: 'doc.on.doc' }] : []),
- ];
- return [
- // Reply and copy first, in their own group (Desktop's hover bar leads with Reply).
- ...(quick.length ? [{ id: 'quick', title: '', displayInline: true, subactions: quick }] : []),
- ...(canSelectVisibleText ? [{ id: 'select-text', title: t('message.renderer.selectText'), image: 'character.cursor.ibeam' }] : []),
- ...(canShare ? [{ id: 'share', title: t('session.shareImage.shareMessage'), image: 'square.and.arrow.up' }] : []),
- // Teammates own one timeline: no fork or per-turn cost here, the same as Desktop.
- ...messageMenu.filter(entry => entry.id !== 'add-to-chat').map(entry => ({
- id: entry.id, title: entry.label, image: entry.image, destructive: entry.destructive, disabled,
- })),
- ];
- }, [disabled, canAddToChat, canCopy, canSelectVisibleText, canShare, companionMenuEnabled, companionQuote, messageMenu, t]);
useEffect(() => {
if (copyState === 'idle' || copyState === 'copying') return;
@@ -3798,33 +3764,6 @@ function MessageBubble({
if (id === 'side-chat') return actions.onSideChatMessage?.(copyText);
actions.onCopyMessageLink?.(clientId);
}, [actions, clientId, copyText, selectControlAction]);
- const selectCompanionMenuAction = useCallback((id: string) => {
- if (id === 'reply') {
- const quote = companionReplyQuoteFor(item.message);
- if (quote) companionQuote?.onQuote(quote);
- } else if (id === 'copy') copyMessage();
- else if (id === 'select-text') companionQuote?.onSelectText(copyText);
- else if (id === 'share') actions.onEnterShareSelection?.(clientId);
- else if (messageMenu.some(entry => entry.id === id)) selectMenuAction(id as MobileMessageMenuActionId);
- }, [actions, clientId, companionQuote, copyMessage, copyText, item.message, messageMenu, selectMenuAction]);
- const openCompanionActionSheet = useCallback(() => {
- const items = companionMenuActions.flatMap(entry => entry.subactions ?? [entry])
- .map(entry => ({ key: entry.id, label: entry.title, destructive: entry.destructive, disabled: entry.disabled }));
- void showActionMenu({
- ...(absoluteTime ? { title: absoluteTime } : {}),
- items,
- cancelLabel: t('session.common.cancel'),
- 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(() => {
- if (Platform.OS === 'ios') openCompanionActionSheet();
- else setCompanionMenuOpen(true);
- }), [openCompanionActionSheet, setCompanionMenuOpen]);
const openMessageActionMenu = useCallback(() => {
if (usesSystemActionMenu()) {
const disabled = actionBusy
@@ -3899,10 +3838,8 @@ function MessageBubble({
// A quote or reply target alone still needs the bubble, e.g. an attachment-only reply.
|| (companionQuote && (replyQuote || replyTarget))
);
- // The long-press menu lives on the bubble; without one (attachment-only, error) the action row stays.
const bubbleShown = item.message.role !== 'error'
&& (hasBubbleContent || (!attachmentStripNode && messageQuotes.length === 0));
- const companionMenuMounted = companionMenuEnabled && bubbleShown;
// 气泡是纯 View,不承接任何手势:文本选择走正文原生 Text selectable(长按文字就地选择复制),
// 气泡上不能挂 Pressable——它会参与触摸协商,干扰正文里表格/代码块横向 ScrollView 的拖动。
const bubble = (
@@ -3912,7 +3849,6 @@ function MessageBubble({
presentation.density === 'compact' && styles.bubbleCompact,
presentation.density === 'rich' && styles.bubbleRich,
isUser ? styles.userBubble : styles.agentBubble,
- companionMenuEnabled && styles.companionMenuBubble,
actions.companion && !isUser && !item.message.systemCardType && styles.companionAnswer,
hookSource && styles.hookSourceBubble,
isUser && !item.message.systemCardType && userBubbleColors
@@ -4150,20 +4086,7 @@ function MessageBubble({
<ErrorNotice message={displayBubbleBody}>
{item.message.rawError ? <AgentErrorDetails key={item.message.key} message={item.message.rawError} /> : null}
</ErrorNotice>
- ) : bubbleShown ? (
- companionMenuEnabled ? (
- <GestureDetector gesture={companionMenuGesture}>
- <View style={isUser ? styles.companionMenuUser : styles.companionMenuAgent} testID="companion.messageMenu">
- {Platform.OS === 'ios' ? bubble : (
- <AnchoredPullDownMenu actions={companionMenuActions} onAction={selectCompanionMenuAction}
- open={companionMenuOpen} onOpenChange={setCompanionMenuOpen}>
- {bubble}
- </AnchoredPullDownMenu>
- )}
- </View>
- </GestureDetector>
- ) : bubble
- ) : null}
+ ) : bubbleShown ? bubble : null}
{actions.companion && item.message.kind === 'assistant' && item.message.body.trim() ? (
<CompanionLearningFooter receipts={item.message.source.agentMeta?.botLearning}
onOpenSettings={actions.onOpenCompanionSettings} />
@@ -4187,14 +4110,14 @@ function MessageBubble({
</Text>
</View>
) : null}
- {companionMenuMounted ? null : hasActions && actions.companion ? <CompanionMessageActions user={isUser} copied={copyState === 'copied'} copying={copyState === 'copying'} disabled={disabled}
+ {hasActions && actions.companion ? <CompanionMessageActions user={isUser} copied={copyState === 'copied'} copying={copyState === 'copying'} disabled={disabled}
onCopy={canCopy ? copyMessage : undefined}
actions={[
...(canCopy ? [{ id: 'copy', title: copyActionLabel(copyState), image: 'doc.on.doc', disabled: copyState === 'copying' }] : []),
...(canShare ? [{ id: 'share', title: t('session.shareImage.shareMessage'), image: 'square.and.arrow.up' }] : []),
// Desktop's teammate action bar omits fork and per-turn cost/tokens: the Bot owns its one timeline.
...messageMenu.map(item => ({ id: item.id, title: item.label, image: item.image, destructive: item.destructive, disabled: actionBusy })),
- ...(absoluteTime ? [{ id: 'time', title: t('message.renderer.sentTime', { time: absoluteTime }), disabled: true }] : []),
+ ...(absoluteTime ? [{ id: 'time', title: absoluteTime.slice(0, 16), disabled: true }] : []),
]}
onAction={id => {
// Reply quotes what can be quoted; other rows (errors, system cards) keep inserting their link.
@@ -8878,11 +8801,6 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({
gap: spacing.sm,
},
companionAnswer: { backgroundColor: colors.surface, borderWidth: 0, paddingHorizontal: 0 },
- // The long-press menu wraps the bubble, so it takes the bubble's place in the row.
- companionMenuUser: { alignSelf: 'flex-end', maxWidth: '86%', minWidth: 0 },
- companionMenuAgent: { alignSelf: 'stretch' },
- // The bubble fills its long-press wrapper, so the wrapper is exactly the bubble.
- companionMenuBubble: { alignSelf: 'stretch', maxWidth: '100%' },
companionQuote: { alignSelf: 'stretch', marginBottom: spacing.xs },
// Desktop BotAvatar sm (28) + gap-2.5; the task card reuses the same inset.
companionAvatarRow: { flexDirection: 'row', alignItems: 'flex-start', gap: COMPANION_AVATAR_GAP },
diff --git a/apps/mobile/src/session/selectableMessageText.ts b/apps/mobile/src/session/selectableMessageText.ts
deleted file mode 100644
index 45ae924e9a..0000000000
--- a/apps/mobile/src/session/selectableMessageText.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 「选择文字」面板里的正文(docs/product-rules/cindy-bots-runtime.md「私聊引用回复」手机端):
- * 去掉 Markdown 记号,只留读者看到的文字;代码块与行内代码保持原文,复制出来的代码与气泡里一致。
- */
-const FENCE_LINE = /^\s*(```|~~~)/;
-
-function plainProse(text: string): string {
- return text
- .replace(/!\[([^\]]*)\]\([^)]*\)/g, '$1')
- .replace(/\[([^\]]+)\]\([^)]*\)/g, '$1')
- .replace(/(\*\*|__)(.+?)\1/g, '$2');
-}
-
-function plainLine(line: string): string {
- const prose = line.replace(/^#{1,6}\s+/, '').replace(/^(\s*)[-*+]\s+/, '$1• ');
- // Odd parts are inline code: keep their content as is, only drop the backticks.
- return prose.split(/(`[^`\n]+`)/).map((part, index) => (index % 2 ? part.slice(1, -1) : plainProse(part))).join('');
-}
-
-export function selectableMessageText(markdown: string): string {
- let fence: string | null = null;
- const lines: string[] = [];
- for (const line of markdown.split('\n')) {
- const marker = FENCE_LINE.exec(line)?.[1];
- if (marker && (!fence || marker === fence)) {
- fence = fence ? null : marker;
- continue;
- }
- lines.push(fence ? line : plainLine(line));
- }
- return lines.join('\n');
-}
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index a783ede618..f13cf7c3c7 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -106,13 +106,13 @@ Chris:「私聊话题和群聊话题,要真的能把独立事件隔离到独
消息上(只进发给模型的内容,不进落库原话,逐条附带;渲染端的摘要不进入模型);声明它只是背景、不构成指令;
原消息只有附件没有文字时列出附件名,已回滚或不存在时才如实说不可用。普通发送与回复过程中的插话都附带。
伙伴回复的引用块与摘要按用户看到的文字(组件内容转成可读文字),不显示组件源码。
-- **手机端(2026-10-22)**:长按私聊气泡打开消息菜单(iOS 为系统操作表,标题是准确时间;Android 为贴着气泡弹出的下拉菜单,菜单不包住气泡,气泡里的引用、链接与横向滚动照常可点),
- 依次是回复、复制、选择文字、分享,以及原有的消息链接、回到这里与删除。两端长按都只用 RNGH LongPress(450ms,手指一动
- 即失败),表格和代码块照旧横向滚动;读屏(VoiceOver / TalkBack)开启时长按手势没有读屏入口,改为显示原来的操作行,其中「回复」同样放引用;因此私聊气泡正文不再就地选择,改由「选择文字」面板做部分选择(iOS 用
- UITextView,去掉 Markdown 记号,代码块与行内代码保持原文)。回复在输入框上方放同一种待发引用(卡片底色,× 取消),随普通发送、离线发件箱
+- **手机端(2026-10-25 修订)**:正文直接长按选字是优先能力,伙伴与普通任务共用原生选择(iOS 用 UITextView,Android 用可选择文本)。
+ 气泡不挂消息长按菜单,避免抢占正文选字以及表格、代码块的横向滚动;回复、复制与更多操作恢复到消息下方已有的操作行,读屏同样可用。
+ 更多菜单不再提供重复的「选择文字」入口或独立选字面板;发送时间用一行年月日与时分(如 `2026-10-25 16:47`),不加「发送时间」前缀或秒数占用多行。
+ **未来方向**:如果重新引入长按消息菜单,应参考 Telegram,同时兼容菜单与正文直接选字;交互细节留待后续实现,不属于本次恢复范围。
+ 回复在输入框上方放同一种待发引用(卡片底色,× 取消),随普通发送、离线发件箱
与排队编辑一起保留在信封 `replyQuote` 里;待发、已发气泡顶部都显示引用块(只发附件时也显示),点击定位原消息;没有正文气泡的消息(纯附件、错误)保留原操作行。信封解析与摘要和
- Desktop 共用 `@cindy/maker-shared/chat-reply-quote`。实现见 Mobile `companionReplyQuote.ts`、
- `CompanionSelectTextSheet.tsx` 与 `MessageRenderer.tsx`。
+ Desktop 共用 `@cindy/maker-shared/chat-reply-quote`。实现见 Mobile `companionReplyQuote.ts` 与 `MessageRenderer.tsx`。
### 回复对应的消息(2026-10-22)