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): 将排队消息操作收进菜单并支持调整顺序

Dash431ab8180f71
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index dbf310ca16..d6a99a8dd7 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -7754,6 +7754,24 @@ function SessionScreenContent() {
});
};
+ const moveQueueItem = useCallback((clientId: string, direction: 'up' | 'down') => {
+ // 菜单打开期间队列可能变化:按最新位置重新判断方向和目标。
+ const projection = remoteSessionStore.getInputProjection(sessionId);
+ const originalIndex = projection.pendingQueue.findIndex((entry) => entry.clientId === clientId);
+ const item = projection.pendingQueue[originalIndex];
+ if (!item) return;
+ const { actions } = buildQueueRowPresentation({
+ busy: queueBusy, item, originalIndex, projection,
+ queueLength: projection.pendingQueue.length,
+ readOnlyReason: queueAvailabilityReason,
+ });
+ const action = actions[direction === 'up' ? 'moveUp' : 'moveDown'];
+ if (action.disabled || action.targetIndex == null) return;
+ const targetIndex = action.targetIndex;
+ setQueueSelectedClientId(null);
+ void runQueueAction(() => maker.input.move(sessionId, clientId, targetIndex));
+ }, [maker, queueAvailabilityReason, queueBusy, runQueueAction, sessionId]);
+
const setQueueEditLock = useCallback((clientId: string, locked: boolean) => {
const projectionEpochAtRequestStart =
remoteSessionStore.captureInputProjectionAuthorityEpoch(sessionId);
@@ -7935,10 +7953,11 @@ function SessionScreenContent() {
setQueueSelectedClientId(null);
steerQueueItem(target);
},
+ onMove: moveQueueItem,
onRetryOutbox: retryOutboxItem,
onRemoveOutbox: removeOutboxItem,
}),
- [beginQueueEdit, queueBusy, queueSelectedClientId, removeQueueItem, removeOutboxItem, retryOutboxItem, sessionId, steerQueueItem],
+ [beginQueueEdit, moveQueueItem, queueBusy, queueSelectedClientId, removeQueueItem, removeOutboxItem, retryOutboxItem, sessionId, steerQueueItem],
);
// ⚠️ 临时取证(定位「气泡凭空消失」,定位完成后删):会话页实例身份 + 挂载/卸载。
diff --git a/apps/mobile/src/__tests__/PendingSendBubble.touch.test.tsx b/apps/mobile/src/__tests__/PendingSendBubble.touch.test.tsx
index e24f4d481d..9630c70a19 100644
--- a/apps/mobile/src/__tests__/PendingSendBubble.touch.test.tsx
+++ b/apps/mobile/src/__tests__/PendingSendBubble.touch.test.tsx
@@ -3,8 +3,10 @@ import { act, type ReactNode } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
import type { GestureResponderEvent } from 'react-native';
+import type { MenuAction } from '@react-native-menu/menu';
import { PendingSendBubble, type PendingSendBubbleActions } from '@/session/PendingSendBubble';
import { MessageBodyText } from '@/session/ShareMessageCheckbox';
+import { buildQueueRowPresentation, EMPTY_INPUT_PROJECTION } from '@/session/inputProjection';
import type { MobilePendingSendItem } from '@/session/pendingSendItems';
import { collectMobileMessageGalleryImages, lightboxImagesForPayload } from '@/session/messageGallery';
@@ -21,16 +23,25 @@ vi.mock('react-native', async () => {
};
class AnimatedValue { setValue() {} interpolate() { return 0; } }
return { View: view('div'), Text: view('span'), Pressable: view('button'), ActivityIndicator: () => null,
+ Platform: { OS: 'ios' }, NativeModules: {}, UIManager: { getViewManagerConfig: () => ({}) },
StyleSheet: { create: (styles: unknown) => styles, hairlineWidth: 1 },
Animated: { View: view('div'), Value: AnimatedValue, timing: () => ({ start() {}, stop() {} }) },
Easing: { bezier: () => (value: number) => value },
AccessibilityInfo: { isReduceMotionEnabled: () => Promise.resolve(true), addEventListener: () => ({ remove() {} }) } };
});
+vi.mock('@react-native-menu/menu', async () => {
+ const { createElement } = await import('react');
+ return { MenuView: (props: Record<string, unknown> & { children?: ReactNode }) => {
+ handlers.set(String(props.testID), props);
+ return createElement('div', { 'data-testid': props.testID }, props.children);
+ } };
+});
+vi.mock('@/platform/chrome/AnchoredPullDownMenu', () => ({ AnchoredPullDownMenu: () => null }));
vi.mock('@/components/AppText', async () => ({ Text: (await import('react-native')).Text }));
-vi.mock('lucide-react-native', () => ({ Check: () => null, AlertCircle: () => null, ArrowUp: () => null,
+vi.mock('lucide-react-native', () => ({ Check: () => null, AlertCircle: () => null, ArrowUp: () => null, ArrowDown: () => null,
ListEnd: () => null, Paperclip: () => null, Pencil: () => null, RotateCcw: () => null, Trash2: () => null,
Bot: () => null, Ghost: () => null, Send: () => null, Timer: () => null,
- Monitor: () => null, Smartphone: () => null, Clock: () => null }));
+ Monitor: () => null, Smartphone: () => null, Clock: () => null, ChevronDown: () => null }));
vi.mock('@/session/SentInlineAtomBody', () => ({ SentInlineAtomBody: () => null }));
vi.mock('@/session/sentAttachmentThumbStore', () => ({ getSentAttachmentThumbUri: (ref: string) => durableThumbs.get(ref) ?? null,
useSentAttachmentThumbsVersion: () => 0 }));
@@ -50,12 +61,18 @@ const openLink = vi.fn();
const openImage = vi.fn();
const removeOutbox = vi.fn();
const retryOutbox = vi.fn();
+const remove = vi.fn();
+const edit = vi.fn();
+const steer = vi.fn();
+const move = vi.fn();
const item: MobilePendingSendItem = {
type: 'pending_send', key: 'message-a', clientId: 'a', phase: 'queued', text: 'hello',
queueIndex: 1, sentInlineTokens: [], thumbs: [], fileCount: 0, attachmentCount: 0, uploadedCount: 0,
errorText: null, hint: null, actions: {
remove: { disabled: false, disabledReason: null }, edit: { disabled: false, disabledReason: null },
steer: { disabled: false, disabledReason: null },
+ moveUp: { disabled: true, disabledReason: null, targetIndex: null },
+ moveDown: { disabled: true, disabledReason: null, targetIndex: null },
},
};
beforeEach(() => {
@@ -73,10 +90,11 @@ function show(
overrides: Partial<MobilePendingSendItem> = {},
selectedClientId: string | null = null,
viewerDeviceId: string | null = null,
+ busy = false,
) {
handlers.clear();
- const actions: PendingSendBubbleActions = { selectedClientId, onSelect: select, onRemove: vi.fn(),
- onBeginEdit: vi.fn(), onSteer: vi.fn(), onRetryOutbox: retryOutbox, onRemoveOutbox: removeOutbox };
+ const actions: PendingSendBubbleActions = { selectedClientId, onSelect: select, onRemove: remove,
+ onBeginEdit: edit, onSteer: steer, onMove: move, onRetryOutbox: retryOutbox, onRemoveOutbox: removeOutbox, busy };
act(() => root.render(<PendingSendBubble item={{ ...item, ...overrides }} actions={actions} viewerDeviceId={viewerDeviceId}
onOpenImage={openImage}
renderImage={() => null} renderFile={() => null}
@@ -150,7 +168,7 @@ it.each(['queued', 'uploading', 'sending', 'settling', 'editing', 'failed'] as c
expect(removeOutbox).not.toHaveBeenCalled();
},
);
-it('opens the host original rather than its local thumbnail and preserves expanded queue actions', () => {
+it('opens the host original rather than its local thumbnail and preserves the queue menu', () => {
show({ thumbs: [{ key: 'a-slot-0', uri: 'file:///photo.jpg', ossRef: 'cindy-media://blobs/photo.jpg',
uploading: false }], attachmentCount: 1 }, 'a');
act(() => host.querySelector<HTMLElement>('[data-testid="pendingSend.image.a-slot-0"]')!.click());
@@ -158,7 +176,7 @@ it('opens the host original rather than its local thumbnail and preserves expand
url: 'cindy-media://blobs/photo.jpg', previewable: false,
});
expect(select).not.toHaveBeenCalled();
- expect(host.querySelector('[data-testid="pendingSend.actions.a"]')).not.toBeNull();
+ expect(host.querySelector('[data-testid="pendingSend.queueStatus.a"]')).not.toBeNull();
});
it('keeps an unavailable upload reference disabled until a local image becomes available', () => {
const thumb = { key: 'a-slot-0', uri: null, ossRef: 'cindy-oss-attach://photo', uploading: false };
@@ -202,10 +220,67 @@ it('shows the source label above the bubble and announces it with the queued mes
const label = host.querySelector('[data-testid="pendingSend.source.a"]');
expect(label?.textContent).toBe('由自动化「巡检」发送');
expect(handlers.get('pendingSend.source.a')?.accessibilityLabel).toBe('由自动化「巡检」发送');
- expect(handlers.get('pendingSend.badge.queued')?.accessibilityLabel).toBe('message.queue.withSource');
+ expect(handlers.get('pendingSend.queueStatus.a')?.accessibilityLabel).toBe('message.queue.withSource');
show();
expect(host.querySelector('[data-testid="pendingSend.source.a"]')).toBeNull();
- expect(handlers.get('pendingSend.badge.queued')?.accessibilityLabel).toBe('message.queue.queuedMessageLabel');
+ expect(handlers.get('pendingSend.queueStatus.a')?.accessibilityLabel).toBe('message.queue.queuedMessageLabel');
+});
+
+// 用户 2026-10-23 要求排队操作收进带图标的原生菜单。现有触摸用例未覆盖菜单桥接:
+// unit 直接渲染 PendingSendBubble,以一条 queued 消息验证原生 action 协议与目标消息,
+// 并验证不可用操作不会因从行内按钮移进菜单而绕过限制。
+it('keeps queue actions inside the native tap menu and routes each choice to its message', () => {
+ show();
+ expect(host.textContent).toContain('message.queue.queued');
+ expect(host.textContent).not.toContain('message.queue.steer');
+ expect(host.querySelector('[data-testid="pendingSend.badge.queued"]')).toBeNull();
+ const menu = handlers.get('pendingSend.queueMenu.a')!;
+ expect(menu.shouldOpenOnLongPress).toBe(false);
+ expect((menu.actions as MenuAction[]).map(({ id, image }) => ({ id, image }))).toEqual([
+ { id: 'steer', image: 'arrow.up' }, { id: 'edit', image: 'pencil' }, { id: 'remove', image: 'trash' },
+ ]);
+ const choose = menu.onPressAction as (event: { nativeEvent: { event: string } }) => void;
+ act(() => { for (const event of ['steer', 'edit', 'remove']) choose({ nativeEvent: { event } }); });
+ expect(steer.mock.calls).toEqual([['a']]);
+ expect(edit.mock.calls).toEqual([['a']]);
+ expect(remove.mock.calls).toEqual([['a']]);
+ expect(select).not.toHaveBeenCalled();
+});
+// 使用生产队列规则覆盖首尾、中间、单条和锁定;验证显示与点击都遵守同一可用性。
+it.each([
+ { length: 1, index: 0, locked: false, expected: [] },
+ { length: 2, index: 0, locked: false, expected: ['moveDown'] },
+ { length: 2, index: 1, locked: false, expected: ['moveUp'] },
+ { length: 3, index: 1, locked: false, expected: ['moveUp', 'moveDown'] },
+ { length: 3, index: 1, locked: true, expected: [] },
+])('shows available move directions for $index of $length, locked=$locked', ({ length, index, locked, expected }) => {
+ const presentation = buildQueueRowPresentation({
+ item: { clientId: 'a', text: 'hello' }, originalIndex: index, queueLength: length,
+ projection: { ...EMPTY_INPUT_PROJECTION, queueEditLocks: locked ? ['a'] : [] },
+ });
+ show({ actions: presentation.actions, queueIndex: index + 1 });
+ const menu = handlers.get('pendingSend.queueMenu.a');
+ const moves = ((menu?.actions ?? []) as MenuAction[]).filter(({ id }) => id === 'moveUp' || id === 'moveDown');
+ expect(moves.map(({ id }) => id)).toEqual(expected);
+ expect(moves.map(({ image }) => image)).toEqual(expected.map((id) => id === 'moveUp' ? 'arrow.up' : 'arrow.down'));
+ if (menu) {
+ const choose = menu.onPressAction as (event: { nativeEvent: { event: string } }) => void;
+ act(() => { for (const event of ['moveUp', 'moveDown']) choose({ nativeEvent: { event } }); });
+ }
+ expect(move.mock.calls).toEqual(expected.map((id) => ['a', id === 'moveUp' ? 'up' : 'down']));
+});
+it('hides unavailable choices and removes the menu while busy or dispatched', () => {
+ show({ actions: { ...item.actions!, steer: { disabled: true, disabledReason: 'Not available' } } });
+ const menu = handlers.get('pendingSend.queueMenu.a')!;
+ expect((menu.actions as MenuAction[]).map(({ id }) => id)).toEqual(['edit', 'remove']);
+ const choose = menu.onPressAction as (event: { nativeEvent: { event: string } }) => void;
+ act(() => choose({ nativeEvent: { event: 'steer' } }));
+ expect(steer).not.toHaveBeenCalled();
+ show({}, null, null, true);
+ expect(handlers.has('pendingSend.queueMenu.a')).toBe(false);
+ expect(handlers.get('pendingSend.queueStatus.a')?.disabled).toBe(true);
+ show({ phase: 'settling', actions: null });
+ expect(host.querySelector('[data-testid="pendingSend.queueStatus.a"]')).toBeNull();
});
it('labels queued input from another device, hides it on the sending device, and keeps it editable', () => {
@@ -217,4 +292,3 @@ it('labels queued input from another device, hides it on the sending device, and
show({ sourceDevice }, null, 'phone-a');
expect(host.querySelector('[data-testid="pendingSend.sourceDevice.a"]')).toBeNull();
});
-
diff --git a/apps/mobile/src/__tests__/anchoredPullDownMenu.test.tsx b/apps/mobile/src/__tests__/anchoredPullDownMenu.test.tsx
index a8d11795dc..4aabdcf3a0 100644
--- a/apps/mobile/src/__tests__/anchoredPullDownMenu.test.tsx
+++ b/apps/mobile/src/__tests__/anchoredPullDownMenu.test.tsx
@@ -193,7 +193,9 @@ const actions: NativePullDownAction[] = [
title: "More",
subactions: [{ id: "more.rename", title: "Rename" }],
},
- { id: "delete", title: "Delete", destructive: true },
+ // 排队菜单的图标在缺少 iOS 原生菜单的兼容包中也要显示(unit,最小一个图标动作)。
+ { id: "delete", title: "Delete", destructive: true,
+ icon: forwardRef(() => <i data-icon="delete" />) },
{ id: "locked", title: "Locked", disabled: true },
];
@@ -271,6 +273,7 @@ describe("Android anchored pull-down menu", () => {
(node) => node.textContent,
);
expect(headers).toEqual(["Sort", "Projects"]);
+ expect(q('[data-testid="pullDownMenu.item.delete"] [data-icon="delete"]')).not.toBeNull();
expect(
q('[data-testid="pullDownMenu.item.sort.time"] [data-icon="Check"]'),
).not.toBeNull();
diff --git a/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx b/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx
index 2e9a98d1bc..43f0f91d2c 100644
--- a/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx
+++ b/apps/mobile/src/__tests__/androidMaterialMenu.test.tsx
@@ -53,7 +53,7 @@ vi.mock("@expo/ui/jetpack-compose", () => {
{children}
</button>
),
- { Text: Slot, TrailingIcon: Slot },
+ { Text: Slot, TrailingIcon: Slot, LeadingIcon: Slot },
);
return {
Box: () => null,
@@ -79,6 +79,8 @@ vi.mock("@/components/AppText", () => ({
}));
vi.mock("@/theme", () => ({
fontWeight: {},
+ iconSize: {},
+ iconStroke: {},
lineHeight: {},
spacing: {},
typeScale: {},
@@ -127,7 +129,9 @@ it("keeps groups, check states, disabled choices and repeated selections in the
],
},
{ id: "locked", title: "Locked", disabled: true },
- { id: "delete", title: "Delete", destructive: true },
+ // 2026-10-23 排队菜单要求动作配图标;由真实菜单入口验证原生图标槽。
+ { id: "delete", title: "Delete", destructive: true,
+ icon: React.forwardRef(() => <i data-icon="delete" />) },
]}
>
<span>Open</span>
@@ -136,6 +140,7 @@ it("keeps groups, check states, disabled choices and repeated selections in the
);
click("Open");
expect(container.textContent).toContain("Order");
+ expect(container.querySelector('[data-icon="delete"]')).not.toBeNull();
click("Time✓");
click("Time✓");
click("Locked");
diff --git a/apps/mobile/src/__tests__/pendingSendItems.test.ts b/apps/mobile/src/__tests__/pendingSendItems.test.ts
index f09401edc5..8e0dac999f 100644
--- a/apps/mobile/src/__tests__/pendingSendItems.test.ts
+++ b/apps/mobile/src/__tests__/pendingSendItems.test.ts
@@ -313,6 +313,8 @@ describe('buildPendingSendItems', () => {
queue: [queued('same')],
presentationByClientId: new Map([['same', {
actions: {
+ moveUp: { disabled: true, disabledReason: null, targetIndex: null },
+ moveDown: { disabled: true, disabledReason: null, targetIndex: null },
remove: { disabled: false, disabledReason: null },
edit: { disabled: false, disabledReason: null },
steer: { disabled: false, disabledReason: null },
@@ -432,6 +434,8 @@ describe('pending_send 渲染接线', () => {
queue: [queued('selected')],
presentationByClientId: new Map([['selected', {
actions: {
+ moveUp: { disabled: true, disabledReason: null, targetIndex: null },
+ moveDown: { disabled: true, disabledReason: null, targetIndex: null },
remove: { disabled: false, disabledReason: null },
edit: { disabled: false, disabledReason: null },
steer: { disabled: false, disabledReason: null },
diff --git a/apps/mobile/src/i18n/locales/en/message.json b/apps/mobile/src/i18n/locales/en/message.json
index ae46501a06..ccbaf023e9 100644
--- a/apps/mobile/src/i18n/locales/en/message.json
+++ b/apps/mobile/src/i18n/locales/en/message.json
@@ -234,6 +234,9 @@
"cancel": "Cancel",
"edit": "Edit",
"steer": "Interject",
+ "moveUp": "Move earlier",
+ "moveDown": "Move later",
+ "cancelSend": "Cancel send",
"collapseQueued": "Collapse queued messages",
"expandRemainingQueued": "Expand {{n}} more queued messages",
"collapse": "Collapse",
diff --git a/apps/mobile/src/i18n/locales/ja/message.json b/apps/mobile/src/i18n/locales/ja/message.json
index 701ae11c40..47a56fd428 100644
--- a/apps/mobile/src/i18n/locales/ja/message.json
+++ b/apps/mobile/src/i18n/locales/ja/message.json
@@ -234,6 +234,9 @@
"cancel": "キャンセル",
"edit": "編集",
"steer": "割り込み",
+ "moveUp": "1つ前へ",
+ "moveDown": "1つ後ろへ",
+ "cancelSend": "送信をキャンセル",
"collapseQueued": "キュー内メッセージを折りたたむ",
"expandRemainingQueued": "残り {{n}} 件のキュー内メッセージを展開",
"collapse": "折りたたむ",
diff --git a/apps/mobile/src/i18n/locales/ko/message.json b/apps/mobile/src/i18n/locales/ko/message.json
index b16bc36ec1..a1934b1d04 100644
--- a/apps/mobile/src/i18n/locales/ko/message.json
+++ b/apps/mobile/src/i18n/locales/ko/message.json
@@ -234,6 +234,9 @@
"cancel": "취소",
"edit": "편집",
"steer": "끼어들기",
+ "moveUp": "한 칸 앞으로",
+ "moveDown": "한 칸 뒤로",
+ "cancelSend": "전송 취소",
"collapseQueued": "대기 중인 메시지 접기",
"expandRemainingQueued": "남은 {{n}}개의 대기 중인 메시지 펼치기",
"collapse": "접기",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/message.json b/apps/mobile/src/i18n/locales/zh-CN/message.json
index a8a36e3223..75a4895c4d 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/message.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/message.json
@@ -234,6 +234,9 @@
"cancel": "取消",
"edit": "编辑",
"steer": "插话",
+ "moveUp": "提前一位",
+ "moveDown": "延后一位",
+ "cancelSend": "取消发送",
"collapseQueued": "收起排队消息",
"expandRemainingQueued": "展开剩余 {{n}} 条排队消息",
"collapse": "收起",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/message.json b/apps/mobile/src/i18n/locales/zh-TW/message.json
index a5ba9c26c5..2aa6ec6c53 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/message.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/message.json
@@ -234,6 +234,9 @@
"cancel": "取消",
"edit": "編輯",
"steer": "插話",
+ "moveUp": "提前一位",
+ "moveDown": "延後一位",
+ "cancelSend": "取消傳送",
"collapseQueued": "收起排隊訊息",
"expandRemainingQueued": "展開剩餘 {{n}} 條排隊訊息",
"collapse": "收起",
diff --git a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx
index af2fc6a8d3..f37311eb9d 100644
--- a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx
+++ b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.android.tsx
@@ -26,7 +26,15 @@ import {
buildPullDownMenuSections,
resolvePullDownSubmenu,
} from "./pullDownMenuModel";
-import { fontWeight, lineHeight, spacing, typeScale, useTheme } from "@/theme";
+import {
+ fontWeight,
+ iconSize,
+ iconStroke,
+ lineHeight,
+ spacing,
+ typeScale,
+ useTheme,
+} from "@/theme";
import { Text as AppText } from "@/components/AppText";
import type { NativePullDownAction } from "./NativePullDownMenu";
@@ -271,6 +279,21 @@ export function AnchoredPullDownMenu({
}}
onClick={() => choose(action)}
>
+ {action.icon ? (
+ <DropdownMenuItem.LeadingIcon>
+ <RNHostView matchContents>
+ <action.icon
+ color={action.disabled
+ ? colors.textTertiary
+ : action.destructive
+ ? colors.destructive
+ : colors.textPrimary}
+ size={iconSize.md}
+ strokeWidth={iconStroke.regular}
+ />
+ </RNHostView>
+ </DropdownMenuItem.LeadingIcon>
+ ) : null}
<DropdownMenuItem.Text>
<Column>
<Text
diff --git a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx
index 4434efd111..34658c52e9 100644
--- a/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx
+++ b/apps/mobile/src/platform/chrome/AnchoredPullDownMenu.tsx
@@ -354,6 +354,7 @@ function MenuRow({
const { colors } = useTheme();
const submenu = !!action.subactions?.length && !action.displayInline;
const tint = action.destructive ? colors.destructive : colors.textPrimary;
+ const Icon = action.icon;
return (
<Pressable
accessibilityLabel={
@@ -392,6 +393,8 @@ function MenuRow({
size={iconSize.md}
strokeWidth={iconStroke.medium}
/>
+ ) : Icon ? (
+ <Icon color={tint} size={iconSize.md} strokeWidth={iconStroke.regular} />
) : null}
</View>
<View style={styles.rowText}>
diff --git a/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx b/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx
index 55321c61a3..a6279bc73c 100644
--- a/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx
+++ b/apps/mobile/src/platform/chrome/NativePullDownMenu.tsx
@@ -1,5 +1,6 @@
import { MenuView, type MenuAction } from "@react-native-menu/menu";
import { cloneElement, isValidElement, type ReactNode } from "react";
+import type { LucideIcon } from "lucide-react-native";
import {
NativeModules,
Platform,
@@ -16,6 +17,8 @@ export type NativePullDownAction = {
displayInline?: boolean;
id: string;
image?: MenuAction["image"];
+ /** 与 iOS image 对应的跨平台菜单图标。 */
+ icon?: LucideIcon;
keepPresented?: boolean;
preferredElementSize?: "small" | "medium" | "large";
state?: "on" | "off" | "mixed";
diff --git a/apps/mobile/src/session/PendingSendBubble.tsx b/apps/mobile/src/session/PendingSendBubble.tsx
index 2ffef77363..a3909b22ff 100644
--- a/apps/mobile/src/session/PendingSendBubble.tsx
+++ b/apps/mobile/src/session/PendingSendBubble.tsx
@@ -7,7 +7,7 @@
* 送达后正式消息的「复制 / …」占的就是这一行,所以前后行高不变。本机刚发出的条目图标延后出现,
* 多数发送在延迟内落定,不闪转圈。左侧图标语义:
* - 转圈 = 还没有「已被收下」这个事实(enqueue 在途 / 已出队待回流 / 附件上传中);
- * - 「排入队尾 list-end」= 已确认入队,顺序由排列先后表达,不标数字;
+ * - 已确认入队:图标与「排队中」合并到下方菜单入口,左侧不重复显示;
* - 时钟 = 电脑离线,消息留在手机上,连上后自动发出(不算失败);
* - ✎ = 正在底部 composer 编辑这一条;
* - ⚠ = 失败,可重试 / 删除。
@@ -20,6 +20,8 @@ import { useReduceMotionEnabled } from '@/hooks/useReduceMotion';
import { CompanionFadeIn } from '@/session/CompanionEntering';
import { LOCAL_SEND_STATUS_DELAY_MS, localSendStartedAt } from '@/session/localSendMotion';
import { Text } from '@/components/AppText';
+import { NativePullDownMenu, usesNativePullDownMenu, type NativePullDownAction } from '@/platform/chrome/NativePullDownMenu';
+import { AnchoredPullDownMenu } from '@/platform/chrome/AnchoredPullDownMenu';
import { buildMessageContentLayout } from '@/session/messageContentLayout';
import { summarizeMessageBubblePresentation } from '@/session/messagePresentation';
import { LONG_USER_MESSAGE_COLLAPSED_LINES, LONG_USER_MESSAGE_VISUAL_LINE_THRESHOLD, mayExceedVisualLineThreshold, resolveUserMessageCollapse } from '@/session/userMessageCollapse';
@@ -29,7 +31,10 @@ import { MessageBodyTapBoundary } from '@/session/ShareMessageCheckbox';
import { shareSelectionTapMoved, shouldCommitShareSelectionTap, type ShareSelectionTapPoint } from '@/session/shareSelectionTap';
import {
AlertCircle,
+ ArrowDown,
+ ArrowUp,
Bot,
+ ChevronDown,
Clock,
Ghost,
ListEnd,
@@ -40,6 +45,7 @@ import {
Send,
Smartphone,
Timer,
+ Trash2,
type LucideIcon,
} from 'lucide-react-native';
import { shouldShowSourceDevice } from '@cindy/maker-shared/message-source';
@@ -94,6 +100,7 @@ export interface PendingSendBubbleActions {
onRemove(clientId: string): void;
onBeginEdit(clientId: string): void;
onSteer(clientId: string): void;
+ onMove(clientId: string, direction: 'up' | 'down'): void;
onRetryOutbox(clientId: string): void;
onRemoveOutbox(clientId: string): void;
busy?: boolean;
@@ -336,6 +343,7 @@ export function PendingSendBubble({
const uploadsPending = item.phase === 'uploading';
const statusShown = useLocalSendStatusShown(item.key);
const waiting = item.phase === 'waiting';
+ const queued = item.phase === 'queued' && !!item.actions;
const failedImages = item.thumbs.filter((thumb) => thumb.failed).length;
// 只有「正在下方输入框编辑」时淡化:那一刻气泡确实在被改写。
const contentOpacity = useAnimatedOpacity(editing ? 0.38 : 1);
@@ -470,7 +478,7 @@ export function PendingSendBubble({
</View>
) : null}
<View style={styles.bubbleRow}>
- <Pressable
+ {!queued ? <Pressable
accessibilityHint={item.hint ?? undefined}
accessibilityLabel={item.source
? t('message.queue.withSource', { source: item.source.label, message: statusLabel })
@@ -499,7 +507,7 @@ export function PendingSendBubble({
)}
</CompanionFadeIn>
)}
- </Pressable>
+ </Pressable> : null}
<Animated.View
style={[styles.content, { opacity: contentOpacity }]}
testID={`pendingSend.bubble.${item.clientId}`}
@@ -632,19 +640,9 @@ export function PendingSendBubble({
</CompanionFadeIn>
) : item.actions && item.phase === 'queued' && statusShown ? (
<CompanionFadeIn distance={0} duration={motionDuration.fast} play={statusShown === 'revealed'}>
- <View style={styles.statusActions} testID={`pendingSend.actions.${item.clientId}`}>
- <Text numberOfLines={1} style={styles.statusText}>{t('message.queue.queued')}</Text>
- <View style={styles.statusDivider} />
- <StatusAction busy={actions.busy} disabled={item.actions.steer.disabled}
- disabledReason={item.actions.steer.disabledReason} label={t('message.queue.steer')}
- onPress={() => actions.onSteer(item.clientId)} testID={`pendingSend.steer.${item.clientId}`} />
- <StatusAction busy={actions.busy} disabled={item.actions.edit.disabled}
- disabledReason={item.actions.edit.disabledReason} label={t('message.queue.edit')}
- onPress={() => actions.onBeginEdit(item.clientId)} testID={`pendingSend.edit.${item.clientId}`} />
- <StatusAction busy={actions.busy} disabled={item.actions.remove.disabled}
- disabledReason={item.actions.remove.disabledReason} label={t('message.queue.cancel')}
- onPress={() => actions.onRemove(item.clientId)} testID={`pendingSend.remove.${item.clientId}`} />
- </View>
+ <QueuedSendMenu item={item} actions={actions} accessibilityLabel={item.source
+ ? t('message.queue.withSource', { source: item.source.label, message: statusLabel })
+ : statusLabel} />
</CompanionFadeIn>
) : selected && outbox && item.canCancel !== false ? (
// 还在上传 / 发出途中:轻点气泡才露出「取消」,平时这一行留空,只有左侧图标。
@@ -667,6 +665,58 @@ export function PendingSendBubble({
);
}
+/** 排队状态与操作共用一个入口,菜单浮在消息上,不展开列表行。 */
+function QueuedSendMenu({ item, actions, accessibilityLabel }: {
+ item: MobilePendingSendItem;
+ actions: PendingSendBubbleActions;
+ accessibilityLabel: string;
+}) {
+ const { t } = useTranslation();
+ const { colors } = useTheme();
+ const styles = useThemedStyles(makeStyles);
+ const choices: NativePullDownAction[] = [
+ { id: 'steer', title: t('message.queue.steer'), image: 'arrow.up', icon: ArrowUp },
+ { id: 'edit', title: t('message.queue.edit'), image: 'pencil', icon: Pencil },
+ { id: 'moveUp', title: t('message.queue.moveUp'), image: 'arrow.up', icon: ArrowUp },
+ { id: 'moveDown', title: t('message.queue.moveDown'), image: 'arrow.down', icon: ArrowDown },
+ { id: 'remove', title: t('message.queue.cancelSend'), image: 'trash', icon: Trash2, destructive: true },
+ ].filter((choice) => {
+ const availability = item.actions?.[choice.id as keyof NonNullable<MobilePendingSendItem['actions']>];
+ return !actions.busy && availability && !availability.disabled;
+ });
+ const disabled = choices.length === 0;
+ const trigger = (
+ <Pressable
+ accessibilityLabel={accessibilityLabel}
+ accessibilityHint={item.hint ?? undefined}
+ accessibilityRole="button"
+ accessibilityState={{ disabled, busy: actions.busy || undefined }}
+ disabled={disabled}
+ style={({ pressed }) => [styles.queueMenuTrigger, pressed && styles.pressed]}
+ testID={`pendingSend.queueStatus.${item.clientId}`}
+ >
+ <ListEnd color={colors.textTertiary} size={iconSize.sm} strokeWidth={iconStroke.regular} />
+ <Text style={styles.queueStatusText}>{t('message.queue.queued')}</Text>
+ {!disabled && <ChevronDown color={colors.textTertiary} size={iconSize.xs} strokeWidth={iconStroke.regular} />}
+ </Pressable>
+ );
+ if (disabled) return trigger;
+ const Menu = usesNativePullDownMenu() ? NativePullDownMenu : AnchoredPullDownMenu;
+ return (
+ <Menu actions={choices} testID={`pendingSend.queueMenu.${item.clientId}`}
+ onAction={(id) => {
+ if (item.phase !== 'queued' || !choices.some((choice) => choice.id === id && !choice.disabled)) return;
+ if (id === 'steer') actions.onSteer(item.clientId);
+ else if (id === 'edit') actions.onBeginEdit(item.clientId);
+ else if (id === 'remove') actions.onRemove(item.clientId);
+ else if (id === 'moveUp') actions.onMove(item.clientId, 'up');
+ else if (id === 'moveDown') actions.onMove(item.clientId, 'down');
+ }}>
+ {trigger}
+ </Menu>
+ );
+}
+
/** 状态行里的文字按钮:13/18 medium,可见高度跟着这一行,命中区用 hitSlop 补到 44。 */
function StatusAction({
busy,
@@ -780,6 +830,8 @@ const makeStyles = (colors: ThemeColors) => StyleSheet.create({
statusRow: { alignItems: 'center', flexDirection: 'row', gap: spacing.xs, height: 46, justifyContent: 'flex-end', marginTop: -spacing.sm, maxWidth: '100%' },
// 按钮自带 44 宽的留白,彼此只留 4 的间距。
statusActions: { alignItems: 'center', alignSelf: 'stretch', flexDirection: 'row', gap: spacing.xs },
+ queueMenuTrigger: { alignItems: 'center', flexDirection: 'row', gap: spacing.xs, minHeight: 44, minWidth: 44 },
+ queueStatusText: { color: colors.textTertiary, fontSize: typeScale.caption, lineHeight: lineHeight.caption, fontWeight: fontWeight.regular },
// 说明 / 报错是成句的话:13/18,二级色;失败用报错色。
statusText: { color: colors.textSecondary, flexShrink: 1, fontSize: typeScale.footnote, lineHeight: lineHeight.caption },
statusError: { color: colors.errorText, flexShrink: 1, fontSize: typeScale.footnote, lineHeight: lineHeight.caption },
diff --git a/apps/mobile/src/session/pendingSendItems.ts b/apps/mobile/src/session/pendingSendItems.ts
index 36c3a95ba9..4fb5c46879 100644
--- a/apps/mobile/src/session/pendingSendItems.ts
+++ b/apps/mobile/src/session/pendingSendItems.ts
@@ -16,7 +16,7 @@ import { forwardedRequestDisplayText } from '@cindy/maker-shared/message-source'
* 未派发条目保持队列 / outbox 顺序。已派发气泡在分组前占据本地用户消息的位置,
* 正式回流以同一个 clientId 原位替换,不比较控制端与主机的时钟。
*/
-import { queueItemVisibleText } from '@cindy/maker-shared/queue';
+import { queueItemVisibleText, type QueueRowPresentation } from '@cindy/maker-shared/queue';
import { syntheticTriggerKind } from '@cindy/maker-shared/synthetic-trigger';
import {
isHookSchedulerOrigin,
@@ -76,12 +76,8 @@ export interface MobilePendingSendSource {
idText?: string;
}
-/** 气泡上的三个队列操作在当前条目上可不可用(由 buildQueueRowPresentation 预先算好)。 */
-export interface MobilePendingSendActions {
- remove: { disabled: boolean; disabledReason: string | null };
- edit: { disabled: boolean; disabledReason: string | null };
- steer: { disabled: boolean; disabledReason: string | null };
-}
+/** 队列操作的可用性与移动目标由共享队列规则计算。 */
+export type MobilePendingSendActions = QueueRowPresentation['actions'];
export interface MobilePendingSendItem {
type: 'pending_send';