Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(chat): multi-select messages and forward to another agent (#16400)

Arvin Xu4dff9c1a5b6f
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index dd66a044ab3..7bd786631fd 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -387,6 +387,28 @@
"messageAction.interruptedHint": "What should I do instead?",
"messageAction.reaction": "Add Reaction",
"messageAction.regenerate": "Regenerate",
+ "messageAction.select": "Select",
+ "messageForward.bar.cancel": "Cancel",
+ "messageForward.bar.delete": "Delete",
+ "messageForward.bar.forward": "Forward",
+ "messageForward.bar.selectToHere": "Select to here",
+ "messageForward.bar.selected": "Selected {{count}}",
+ "messageForward.deleteConfirm.desc": "Delete the selected {{count}} messages? This cannot be undone.",
+ "messageForward.deleteConfirm.success": "Deleted {{count}} messages",
+ "messageForward.deleteConfirm.title": "Delete messages",
+ "messageForward.empty": "Select at least one message to forward",
+ "messageForward.modal.empty": "No other agents available",
+ "messageForward.modal.noRecipients": "Pick agents on the left to forward to",
+ "messageForward.modal.notePlaceholder": "Add a note (optional) — sent along with the messages",
+ "messageForward.modal.recipients": "Send to ({{count}})",
+ "messageForward.modal.searchPlaceholder": "Search agents…",
+ "messageForward.modal.sendCount": "Forward ({{count}})",
+ "messageForward.modal.title": "Forward to Agent",
+ "messageForward.role.assistant": "Assistant",
+ "messageForward.role.user": "User",
+ "messageForward.success": "Forwarded to {{title}}",
+ "messageForward.successMulti": "Forwarded to {{count}} agents",
+ "messageForward.transcript.header": "The following {{count}} messages were forwarded from another conversation. Please use them as context and continue:",
"messageLongCollapse.collapse": "Show less",
"messageLongCollapse.expand": "Show more",
"messages.dm.sentTo": "Visible only to {{name}}",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 546cb1cba38..db27733f730 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -387,6 +387,28 @@
"messageAction.interruptedHint": "接下来需要做什么?",
"messageAction.reaction": "添加表情",
"messageAction.regenerate": "重新生成",
+ "messageAction.select": "多选",
+ "messageForward.bar.cancel": "取消",
+ "messageForward.bar.delete": "删除",
+ "messageForward.bar.forward": "转发",
+ "messageForward.bar.selectToHere": "选择到这里",
+ "messageForward.bar.selected": "已选 {{count}} 条",
+ "messageForward.deleteConfirm.desc": "确定删除选中的 {{count}} 条消息?此操作不可撤销。",
+ "messageForward.deleteConfirm.success": "已删除 {{count}} 条消息",
+ "messageForward.deleteConfirm.title": "删除消息",
+ "messageForward.empty": "请至少选择一条消息进行转发",
+ "messageForward.modal.empty": "没有可转发的其他智能体",
+ "messageForward.modal.noRecipients": "从左侧选择要转发到的智能体",
+ "messageForward.modal.notePlaceholder": "附加信息(可选),将随转发内容一起发送",
+ "messageForward.modal.recipients": "发送给({{count}})",
+ "messageForward.modal.searchPlaceholder": "搜索智能体…",
+ "messageForward.modal.sendCount": "转发({{count}})",
+ "messageForward.modal.title": "转发给智能体",
+ "messageForward.role.assistant": "助手",
+ "messageForward.role.user": "用户",
+ "messageForward.success": "已转发给 {{title}}",
+ "messageForward.successMulti": "已转发给 {{count}} 个智能体",
+ "messageForward.transcript.header": "以下 {{count}} 条消息转发自另一段对话,请将其作为上下文并继续处理:",
"messageLongCollapse.collapse": "收起",
"messageLongCollapse.expand": "展开全部",
"messages.dm.sentTo": "仅对 {{name}} 可见",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 6cadfcd714a..ba5ed37bf8e 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -315,6 +315,30 @@ export default {
'messageAction.expand': 'Expand Message',
'messageAction.reaction': 'Add Reaction',
'messageAction.regenerate': 'Regenerate',
+ 'messageAction.select': 'Select',
+ 'messageForward.bar.cancel': 'Cancel',
+ 'messageForward.bar.delete': 'Delete',
+ 'messageForward.bar.forward': 'Forward',
+ 'messageForward.bar.selectToHere': 'Select to here',
+ 'messageForward.bar.selected': 'Selected {{count}}',
+ 'messageForward.deleteConfirm.desc':
+ 'Delete the selected {{count}} messages? This cannot be undone.',
+ 'messageForward.deleteConfirm.success': 'Deleted {{count}} messages',
+ 'messageForward.deleteConfirm.title': 'Delete messages',
+ 'messageForward.empty': 'Select at least one message to forward',
+ 'messageForward.modal.empty': 'No other agents available',
+ 'messageForward.modal.noRecipients': 'Pick agents on the left to forward to',
+ 'messageForward.modal.notePlaceholder': 'Add a note (optional) — sent along with the messages',
+ 'messageForward.modal.recipients': 'Send to ({{count}})',
+ 'messageForward.modal.searchPlaceholder': 'Search agents…',
+ 'messageForward.modal.sendCount': 'Forward ({{count}})',
+ 'messageForward.modal.title': 'Forward to Agent',
+ 'messageForward.role.assistant': 'Assistant',
+ 'messageForward.role.user': 'User',
+ 'messageForward.success': 'Forwarded to {{title}}',
+ 'messageForward.successMulti': 'Forwarded to {{count}} agents',
+ 'messageForward.transcript.header':
+ 'The following {{count}} messages were forwarded from another conversation. Please use them as context and continue:',
'messageLongCollapse.collapse': 'Show less',
'messageLongCollapse.expand': 'Show more',
'messages.dm.sentTo': 'Visible only to {{name}}',
diff --git a/src/features/Conversation/ChatList/components/VirtualizedList.tsx b/src/features/Conversation/ChatList/components/VirtualizedList.tsx
index 9b360259360..3b18b48c610 100644
--- a/src/features/Conversation/ChatList/components/VirtualizedList.tsx
+++ b/src/features/Conversation/ChatList/components/VirtualizedList.tsx
@@ -10,6 +10,7 @@ import { useShallow } from 'zustand/react/shallow';
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
import WideScreenContainer from '../../../WideScreenContainer';
+import { MessageForwardSelectToHere } from '../../MessageForward';
import {
dataSelectors,
inputSelectors,
@@ -276,6 +277,8 @@ const VirtualizedList = memo<VirtualizedListProps>(
onTouchMoveCapture={markUserScrollIntent}
onWheelCapture={markUserScrollIntent}
>
+ {/* Pinned to the list viewport top; only renders while multi-selecting */}
+ <MessageForwardSelectToHere />
{/* Debug Inspector - placed outside VList so it won't be recycled by the virtual list */}
{OPEN_DEV_INSPECTOR && <DebugInspector />}
<VList
diff --git a/src/features/Conversation/MessageForward/ForwardMessageDispatcher.tsx b/src/features/Conversation/MessageForward/ForwardMessageDispatcher.tsx
new file mode 100644
index 00000000000..0c67361eee4
--- /dev/null
+++ b/src/features/Conversation/MessageForward/ForwardMessageDispatcher.tsx
@@ -0,0 +1,71 @@
+'use client';
+
+import { useEffect, useMemo, useRef } from 'react';
+import { useLocation } from 'react-router';
+
+import { useAgentStore } from '@/store/agent';
+import { agentSelectors } from '@/store/agent/selectors';
+
+import { useConversationStore } from '../store';
+import { canConsumePendingForward } from './forwardDispatch';
+import { useForwardDispatchStore } from './forwardDispatchStore';
+
+/**
+ * Drains a parked forward once the target agent's fresh conversation is the
+ * active, ready one — sending the forwarded transcript as its opening turn.
+ *
+ * Mirrors the overlay-dispatch effect in `MessageFromUrl`: navigation updates
+ * the URL before the ConversationStore context catches up, so we gate on the
+ * route agentId matching the store agentId and a not-yet-created topic.
+ */
+const ForwardMessageDispatcher = () => {
+ const [sendMessage, context] = useConversationStore((s) => [s.sendMessage, s.context]);
+ const agentId = context.agentId;
+ const location = useLocation();
+ const isAgentConfigLoading = useAgentStore(agentSelectors.isAgentConfigLoading);
+ const [pendingForward, clearPendingForward] = useForwardDispatchStore((s) => [
+ s.pendingForward,
+ s.clearPendingForward,
+ ]);
+
+ const routeAgentId = useMemo(() => {
+ const match = location.pathname?.match(/^\/agent\/([^#/?]+)/);
+ return match?.[1];
+ }, [location.pathname]);
+
+ const lastProcessedRef = useRef<string | null>(null);
+
+ useEffect(() => {
+ if (
+ !canConsumePendingForward({
+ agentId,
+ isAgentConfigLoading,
+ pendingForward,
+ routeAgentId,
+ topicId: context.topicId,
+ })
+ ) {
+ return;
+ }
+
+ if (lastProcessedRef.current === pendingForward!.dispatchId) return;
+ lastProcessedRef.current = pendingForward!.dispatchId;
+
+ const { content, dispatchId } = pendingForward!;
+ clearPendingForward(dispatchId);
+
+ void sendMessage({ message: content });
+ }, [
+ agentId,
+ clearPendingForward,
+ context.topicId,
+ isAgentConfigLoading,
+ pendingForward,
+ routeAgentId,
+ sendMessage,
+ ]);
+
+ return null;
+};
+
+export default ForwardMessageDispatcher;
diff --git a/src/features/Conversation/MessageForward/ForwardModal.tsx b/src/features/Conversation/MessageForward/ForwardModal.tsx
new file mode 100644
index 00000000000..a69697e153e
--- /dev/null
+++ b/src/features/Conversation/MessageForward/ForwardModal.tsx
@@ -0,0 +1,258 @@
+'use client';
+
+import { ActionIcon, Flexbox, SearchBar, Text } from '@lobehub/ui';
+import { Button, Modal } from '@lobehub/ui/base-ui';
+import { Input } from 'antd';
+import { createStaticStyles, cssVar, cx } from 'antd-style';
+import isEqual from 'fast-deep-equal';
+import { X } from 'lucide-react';
+import { memo, useMemo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useFetchAgentList } from '@/hooks/useFetchAgentList';
+import AgentAvatar from '@/routes/(main)/home/_layout/Body/Agent/List/AgentItem/Avatar';
+import { useHomeStore } from '@/store/home';
+import { homeAgentListSelectors } from '@/store/home/selectors';
+
+import { contextSelectors, useConversationStore } from '../store';
+import SelectCircle from './SelectCircle';
+import { type ForwardTarget, useForwardMessages } from './useForwardMessages';
+
+const styles = createStaticStyles(({ css }) => ({
+ body: css`
+ block-size: 460px;
+ `,
+ divider: css`
+ align-self: stretch;
+ inline-size: 1px;
+ background: ${cssVar.colorBorderSecondary};
+ `,
+ list: css`
+ overflow-y: auto;
+ flex: 1;
+ margin-inline: -4px;
+ padding-inline: 4px;
+ `,
+ preview: css`
+ overflow-y: auto;
+ flex: 1;
+
+ padding-block: 10px;
+ padding-inline: 12px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ previewLine: css`
+ overflow: hidden;
+
+ font-size: 12px;
+ color: ${cssVar.colorTextSecondary};
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
+ recipientRemove: css`
+ opacity: 0;
+ `,
+ row: css`
+ cursor: pointer;
+
+ min-block-size: 44px;
+ padding-block: 6px;
+ padding-inline: 8px;
+ border-radius: ${cssVar.borderRadiusLG};
+
+ transition: background-color 0.1s ${cssVar.motionEaseInOut};
+
+ &:hover {
+ background-color: ${cssVar.colorFillTertiary};
+
+ [data-remove] {
+ opacity: 1;
+ }
+ }
+ `,
+ rowSelected: css`
+ background-color: ${cssVar.colorFillQuaternary};
+ `,
+}));
+
+interface ForwardModalProps {
+ onClose: () => void;
+ open: boolean;
+}
+
+const ForwardModal = memo<ForwardModalProps>(({ open, onClose }) => {
+ const { t } = useTranslation('chat');
+ const [keyword, setKeyword] = useState('');
+ const [selectedIds, setSelectedIds] = useState<string[]>([]);
+ const [note, setNote] = useState('');
+ const currentAgentId = useConversationStore(contextSelectors.agentId);
+ const agents = useHomeStore(homeAgentListSelectors.allAgents);
+ const forwardMessages = useForwardMessages();
+
+ // What's being forwarded — count + a few role-labelled snippets for the panel.
+ const preview = useConversationStore((s) => {
+ const selected = new Set(s.selectedMessageIds);
+ const msgs = s.displayMessages.filter((m) => selected.has(m.id));
+ return {
+ count: msgs.length,
+ lines: msgs.slice(0, 6).map((m) => ({
+ role:
+ m.role === 'user' ? t('messageForward.role.user') : t('messageForward.role.assistant'),
+ text: (m.content ?? '').replaceAll(/\s+/g, ' ').slice(0, 60),
+ })),
+ };
+ }, isEqual);
+
+ useFetchAgentList();
+
+ const candidates = useMemo(() => {
+ const trimmed = keyword.trim().toLowerCase();
+ return agents
+ .filter((agent) => agent.type === 'agent' && agent.id !== currentAgentId)
+ .filter((agent) => !trimmed || (agent.title || '').toLowerCase().includes(trimmed));
+ }, [agents, currentAgentId, keyword]);
+
+ const selectedAgents = useMemo(
+ () =>
+ selectedIds
+ .map((id) => agents.find((a) => a.id === id))
+ .filter((a): a is NonNullable<typeof a> => !!a),
+ [selectedIds, agents],
+ );
+
+ const toggle = (id: string) =>
+ setSelectedIds((prev) => (prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id]));
+
+ const handleClose = () => {
+ setSelectedIds([]);
+ setKeyword('');
+ setNote('');
+ onClose();
+ };
+
+ const handleForward = () => {
+ const targets: ForwardTarget[] = selectedAgents.map((a) => ({ id: a.id, title: a.title }));
+ if (targets.length === 0) return;
+ forwardMessages(targets, note);
+ handleClose();
+ };
+
+ const avatarOf = (avatar: unknown) => (typeof avatar === 'string' ? avatar : undefined);
+
+ return (
+ <Modal
+ destroyOnHidden
+ footer={null}
+ open={open}
+ title={t('messageForward.modal.title')}
+ width={760}
+ onCancel={handleClose}
+ >
+ <Flexbox horizontal className={styles.body} gap={16}>
+ {/* Left: searchable multi-select agent list */}
+ <Flexbox flex={1} gap={8} style={{ minWidth: 0 }}>
+ <SearchBar
+ allowClear
+ placeholder={t('messageForward.modal.searchPlaceholder')}
+ value={keyword}
+ onChange={(e) => setKeyword(e.target.value)}
+ />
+ <Flexbox className={styles.list} gap={2}>
+ {candidates.length === 0 ? (
+ <Flexbox align={'center'} justify={'center'} padding={24}>
+ <Text type={'secondary'}>{t('messageForward.modal.empty')}</Text>
+ </Flexbox>
+ ) : (
+ candidates.map((agent) => {
+ const checked = selectedIds.includes(agent.id);
+ return (
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={cx(styles.row, checked && styles.rowSelected)}
+ gap={10}
+ key={agent.id}
+ onClick={() => toggle(agent.id)}
+ >
+ <SelectCircle checked={checked} />
+ <AgentAvatar avatar={avatarOf(agent.avatar)} />
+ <Text ellipsis style={{ flex: 1 }}>
+ {agent.title || t('untitledAgent')}
+ </Text>
+ </Flexbox>
+ );
+ })
+ )}
+ </Flexbox>
+ </Flexbox>
+
+ <div className={styles.divider} />
+
+ {/* Right: recipients + forwarded content + note */}
+ <Flexbox flex={1} gap={10} style={{ minWidth: 0 }}>
+ <Text strong>{t('messageForward.modal.recipients', { count: selectedIds.length })}</Text>
+ <Flexbox gap={2} style={{ maxHeight: 140, minHeight: 44, overflowY: 'auto' }}>
+ {selectedAgents.length === 0 ? (
+ <Text style={{ fontSize: 12, padding: '8px 0' }} type={'secondary'}>
+ {t('messageForward.modal.noRecipients')}
+ </Text>
+ ) : (
+ selectedAgents.map((agent) => (
+ <Flexbox horizontal align={'center'} className={styles.row} gap={10} key={agent.id}>
+ <AgentAvatar avatar={avatarOf(agent.avatar)} />
+ <Text ellipsis style={{ flex: 1 }}>
+ {agent.title || t('untitledAgent')}
+ </Text>
+ <ActionIcon
+ data-remove
+ className={styles.recipientRemove}
+ icon={X}
+ size={'small'}
+ onClick={() => toggle(agent.id)}
+ />
+ </Flexbox>
+ ))
+ )}
+ </Flexbox>
+
+ <Flexbox className={styles.preview} gap={3}>
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {t('messageForward.transcript.header', { count: preview.count })}
+ </Text>
+ {preview.lines.map((line, i) => (
+ <div className={styles.previewLine} key={i}>
+ <Text strong style={{ fontSize: 12 }}>
+ {line.role}:
+ </Text>{' '}
+ {line.text}
+ </div>
+ ))}
+ </Flexbox>
+
+ <Input.TextArea
+ autoSize={{ maxRows: 4, minRows: 2 }}
+ placeholder={t('messageForward.modal.notePlaceholder')}
+ value={note}
+ onChange={(e) => setNote(e.target.value)}
+ />
+
+ <Flexbox horizontal gap={8} justify={'flex-end'}>
+ <Button onClick={handleClose}>{t('messageForward.bar.cancel')}</Button>
+ <Button disabled={selectedIds.length === 0} type={'primary'} onClick={handleForward}>
+ {selectedIds.length > 0
+ ? t('messageForward.modal.sendCount', { count: selectedIds.length })
+ : t('messageForward.bar.forward')}
+ </Button>
+ </Flexbox>
+ </Flexbox>
+ </Flexbox>
+ </Modal>
+ );
+});
+
+ForwardModal.displayName = 'ForwardModal';
+
+export default ForwardModal;
diff --git a/src/features/Conversation/MessageForward/MessageForwardFooter.tsx b/src/features/Conversation/MessageForward/MessageForwardFooter.tsx
new file mode 100644
index 00000000000..9d88c73ce72
--- /dev/null
+++ b/src/features/Conversation/MessageForward/MessageForwardFooter.tsx
@@ -0,0 +1,30 @@
+'use client';
+
+import { memo, type ReactNode } from 'react';
+
+import { messageStateSelectors, useConversationStore } from '../store';
+import SelectionFooterBar from './SelectionFooterBar';
+
+interface MessageForwardFooterProps {
+ children: ReactNode;
+}
+
+/**
+ * Wraps the chat composer: while multi-selecting it hides the input and shows
+ * the selection action bar in its place (WeChat-style). The input stays mounted
+ * but display:none so the editor/draft state survives toggling selection mode.
+ */
+const MessageForwardFooter = memo<MessageForwardFooterProps>(({ children }) => {
+ const isSelectionMode = useConversationStore(messageStateSelectors.isSelectionMode);
+
+ return (
+ <>
+ <div style={isSelectionMode ? { display: 'none' } : { display: 'contents' }}>{children}</div>
+ {isSelectionMode && <SelectionFooterBar />}
+ </>
+ );
+});
+
+MessageForwardFooter.displayName = 'MessageForwardFooter';
+
+export default MessageForwardFooter;
diff --git a/src/features/Conversation/MessageForward/MessageSelectionWrapper.tsx b/src/features/Conversation/MessageForward/MessageSelectionWrapper.tsx
new file mode 100644
index 00000000000..13b42b3fb5e
--- /dev/null
+++ b/src/features/Conversation/MessageForward/MessageSelectionWrapper.tsx
@@ -0,0 +1,115 @@
+'use client';
+
+import { Flexbox } from '@lobehub/ui';
+import { createStaticStyles, cssVar, cx } from 'antd-style';
+import { memo, type ReactNode, useCallback } from 'react';
+
+import { messageStateSelectors, useConversationStore } from '../store';
+import { isSelectableRole } from './selectableRoles';
+import SelectCircle from './SelectCircle';
+
+const styles = createStaticStyles(({ css }) => ({
+ // Nudge the circle down so it lines up with the message's first line instead
+ // of floating at the very top of the row.
+ checkbox: css`
+ flex: none;
+ padding-block-start: 6px;
+ `,
+ content: css`
+ /* Content is non-interactive while selecting — the whole row is the toggle. */
+ pointer-events: none;
+ flex: 1;
+ min-width: 0;
+
+ /* The hover action bar is suppressed in selection mode, so collapse its 28px
+ placeholder too — otherwise every selected row carries a big empty
+ highlighted strip beneath the bubble. */
+ [data-user-action-bar-portal],
+ [data-assitant-action-bar-portal],
+ [data-assistant-group-action-bar-portal] {
+ display: none;
+ }
+ `,
+ // Assistant turns (esp. tool-call workflows) are long; fold them to a preview
+ // height while selecting so the list stays scannable. Fades out at the bottom.
+ contentCollapsed: css`
+ overflow: hidden;
+ max-height: 84px;
+
+ mask-image: linear-gradient(to bottom, #000 56%, transparent 100%);
+ `,
+ disabled: css`
+ cursor: not-allowed;
+ opacity: 0.4;
+ `,
+ // Full-width single-row band, WeChat-style. Kept light: selection uses the
+ // weakest fill (the filled circle is the real indicator); hover is one notch
+ // up purely for transient feedback.
+ row: css`
+ cursor: pointer;
+ inline-size: 100%;
+ padding-inline: 12px;
+ transition: background-color 0.1s ${cssVar.motionEaseInOut};
+
+ &:hover {
+ background-color: ${cssVar.colorFillTertiary};
+ }
+ `,
+ rowSelected: css`
+ background-color: ${cssVar.colorFillQuaternary};
+
+ &:hover {
+ background-color: ${cssVar.colorFillQuaternary};
+ }
+ `,
+}));
+
+interface MessageSelectionWrapperProps {
+ children: ReactNode;
+ id: string;
+ role?: string;
+}
+
+/**
+ * In multi-select mode, wraps a message with a leading round checkbox and turns
+ * the whole full-width row into a single toggle target. Outside selection mode
+ * it renders the message untouched.
+ */
+const MessageSelectionWrapper = memo<MessageSelectionWrapperProps>(({ children, id, role }) => {
+ const isSelectionMode = useConversationStore(messageStateSelectors.isSelectionMode);
+ const isSelected = useConversationStore(messageStateSelectors.isMessageSelected(id));
+ const toggleMessageSelected = useConversationStore((s) => s.toggleMessageSelected);
+
+ const selectable = isSelectableRole(role);
+ const isAssistant = role === 'assistant' || role === 'assistantGroup';
+
+ const handleToggle = useCallback(() => {
+ if (!selectable) return;
+ toggleMessageSelected(id);
+ }, [selectable, toggleMessageSelected, id]);
+
+ if (!isSelectionMode) return <>{children}</>;
+
+ if (!selectable) {
+ return <div className={styles.disabled}>{children}</div>;
+ }
+
+ return (
+ <Flexbox
+ horizontal
+ align={'flex-start'}
+ className={cx(styles.row, isSelected && styles.rowSelected)}
+ gap={8}
+ onClick={handleToggle}
+ >
+ <div className={styles.checkbox}>
+ <SelectCircle checked={isSelected} />
+ </div>
+ <div className={cx(styles.content, isAssistant && styles.contentCollapsed)}>{children}</div>
+ </Flexbox>
+ );
+});
+
+MessageSelectionWrapper.displayName = 'MessageSelectionWrapper';
+
+export default MessageSelectionWrapper;
diff --git a/src/features/Conversation/MessageForward/SelectCircle.tsx b/src/features/Conversation/MessageForward/SelectCircle.tsx
new file mode 100644
index 00000000000..85326b860dd
--- /dev/null
+++ b/src/features/Conversation/MessageForward/SelectCircle.tsx
@@ -0,0 +1,46 @@
+'use client';
+
+import { Center, Icon } from '@lobehub/ui';
+import { createStaticStyles, cssVar, cx } from 'antd-style';
+import { Check } from 'lucide-react';
+import { memo } from 'react';
+
+const styles = createStaticStyles(({ css }) => ({
+ checked: css`
+ border-color: ${cssVar.colorPrimary};
+ color: ${cssVar.colorBgContainer};
+ background: ${cssVar.colorPrimary};
+ `,
+ circle: css`
+ flex: none;
+
+ inline-size: 20px;
+ block-size: 20px;
+ border: 1.5px solid ${cssVar.colorBorder};
+ border-radius: 50%;
+
+ transition:
+ background-color 0.15s ${cssVar.motionEaseInOut},
+ border-color 0.15s ${cssVar.motionEaseInOut};
+ `,
+}));
+
+interface SelectCircleProps {
+ checked?: boolean;
+ className?: string;
+}
+
+/**
+ * WeChat-style round selection indicator: a hollow circle that fills with the
+ * primary color and a check when selected. Replaces the square antd Checkbox in
+ * multi-select rows.
+ */
+const SelectCircle = memo<SelectCircleProps>(({ checked, className }) => (
+ <Center className={cx(styles.circle, checked && styles.checked, className)}>
+ {checked && <Icon icon={Check} size={13} />}
+ </Center>
+));
+
+SelectCircle.displayName = 'SelectCircle';
+
+export default SelectCircle;
diff --git a/src/features/Conversation/MessageForward/SelectToHereButton.tsx b/src/features/Conversation/MessageForward/SelectToHereButton.tsx
new file mode 100644
index 00000000000..f6aed894bd0
--- /dev/null
+++ b/src/features/Conversation/MessageForward/SelectToHereButton.tsx
@@ -0,0 +1,57 @@
+'use client';
+
+import { Icon } from '@lobehub/ui';
+import { Button } from '@lobehub/ui/base-ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { ArrowDownToLine } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { messageStateSelectors, useConversationStore } from '../store';
+
+const styles = createStaticStyles(({ css }) => ({
+ wrap: css`
+ pointer-events: none;
+
+ position: absolute;
+ z-index: 50;
+ inset-block-start: 12px;
+ inset-inline-start: 16px;
+
+ > * {
+ pointer-events: auto;
+ background: ${cssVar.colorBgElevated};
+ box-shadow: ${cssVar.boxShadowSecondary};
+ }
+ `,
+}));
+
+/**
+ * Pinned-to-top "select to here" affordance shown while multi-selecting: selects
+ * every message from the top of the conversation down to the anchor. Mirrors
+ * WeChat's "选择到这里". Renders nothing outside selection mode.
+ */
+const SelectToHereButton = memo(() => {
+ const { t } = useTranslation('chat');
+ const isSelectionMode = useConversationStore(messageStateSelectors.isSelectionMode);
+ const selectToHere = useConversationStore((s) => s.selectToHere);
+
+ if (!isSelectionMode) return null;
+
+ return (
+ <div className={styles.wrap}>
+ <Button
+ icon={<Icon icon={ArrowDownToLine} />}
+ shape={'round'}
+ size={'small'}
+ onClick={selectToHere}
+ >
+ {t('messageForward.bar.selectToHere')}
+ </Button>
+ </div>
+ );
+});
+
+SelectToHereButton.displayName = 'MessageForwardSelectToHereButton';
+
+export default SelectToHereButton;
diff --git a/src/features/Conversation/MessageForward/SelectionFooterBar.tsx b/src/features/Conversation/MessageForward/SelectionFooterBar.tsx
new file mode 100644
index 00000000000..dcfb1b56728
--- /dev/null
+++ b/src/features/Conversation/MessageForward/SelectionFooterBar.tsx
@@ -0,0 +1,155 @@
+'use client';
+
+import { Center, Flexbox, Icon, Text } from '@lobehub/ui';
+import { confirmModal } from '@lobehub/ui/base-ui';
+import { App } from 'antd';
+import { createStaticStyles, cssVar, cx } from 'antd-style';
+import { Forward, type LucideIcon, Trash2, X } from 'lucide-react';
+import { type FC, memo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { messageStateSelectors, useConversationStore } from '../store';
+import ForwardModal from './ForwardModal';
+
+const styles = createStaticStyles(({ css }) => ({
+ action: css`
+ cursor: pointer;
+ user-select: none;
+
+ &:hover [data-icon-box] {
+ background: ${cssVar.colorFillSecondary};
+ }
+ `,
+ actionDisabled: css`
+ cursor: not-allowed;
+ opacity: 0.35;
+
+ &:hover [data-icon-box] {
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+ bar: css`
+ min-block-size: 92px;
+ padding-block: 12px;
+ padding-inline: 16px;
+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};
+
+ background: ${cssVar.colorBgContainer};
+ `,
+ count: css`
+ position: absolute;
+ inset-block-start: 12px;
+ inset-inline-start: 16px;
+ `,
+ iconBox: css`
+ inline-size: 46px;
+ block-size: 46px;
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorFillTertiary};
+
+ transition: background-color 0.1s ${cssVar.motionEaseInOut};
+ `,
+ iconBoxDanger: css`
+ color: ${cssVar.colorError};
+ `,
+}));
+
+interface ActionColumnProps {
+ danger?: boolean;
+ disabled?: boolean;
+ icon: LucideIcon;
+ label: string;
+ onClick: () => void;
+}
+
+const ActionColumn: FC<ActionColumnProps> = ({ icon, label, onClick, disabled, danger }) => (
+ <Flexbox
+ align={'center'}
+ className={cx(styles.action, disabled && styles.actionDisabled)}
+ gap={6}
+ onClick={disabled ? undefined : onClick}
+ >
+ <Center data-icon-box className={cx(styles.iconBox, danger && styles.iconBoxDanger)}>
+ <Icon icon={icon} size={20} />
+ </Center>
+ <Text
+ style={{ color: danger ? cssVar.colorError : undefined, fontSize: 12 }}
+ type={'secondary'}
+ >
+ {label}
+ </Text>
+ </Flexbox>
+);
+
+/**
+ * Bottom action bar that replaces the chat input while multi-selecting. Styled
+ * like WeChat's forward toolbar: a row of labelled icon buttons at a height
+ * close to the composer it stands in for.
+ */
+const SelectionFooterBar = memo(() => {
+ const { t } = useTranslation('chat');
+ const { message } = App.useApp();
+ const [modalOpen, setModalOpen] = useState(false);
+ const selectedCount = useConversationStore(messageStateSelectors.selectedMessageCount);
+ const selectedMessageIds = useConversationStore((s) => s.selectedMessageIds);
+ const exitSelectionMode = useConversationStore((s) => s.exitSelectionMode);
+ const deleteMessages = useConversationStore((s) => s.deleteMessages);
+
+ const disabled = selectedCount === 0;
+
+ const handleDelete = () => {
+ confirmModal({
+ cancelText: t('cancel', { ns: 'common' }),
+ content: t('messageForward.deleteConfirm.desc', { count: selectedCount }),
+ okButtonProps: { danger: true },
+ okText: t('delete', { ns: 'common' }),
+ onOk: async () => {
+ await deleteMessages([...selectedMessageIds]);
+ exitSelectionMode();
+ message.success(t('messageForward.deleteConfirm.success', { count: selectedCount }));
+ },
+ title: t('messageForward.deleteConfirm.title'),
+ });
+ };
+
+ return (
+ <>
+ <Flexbox
+ align={'center'}
+ className={styles.bar}
+ justify={'center'}
+ style={{ position: 'relative' }}
+ >
+ <Text className={styles.count} type={'secondary'}>
+ {t('messageForward.bar.selected', { count: selectedCount })}
+ </Text>
+ <Flexbox horizontal align={'center'} gap={44} justify={'center'}>
+ <ActionColumn
+ disabled={disabled}
+ icon={Forward}
+ label={t('messageForward.bar.forward')}
+ onClick={() => setModalOpen(true)}
+ />
+ <ActionColumn
+ danger
+ disabled={disabled}
+ icon={Trash2}
+ label={t('messageForward.bar.delete')}
+ onClick={handleDelete}
+ />
+ <ActionColumn
+ icon={X}
+ label={t('messageForward.bar.cancel')}
+ onClick={exitSelectionMode}
+ />
+ </Flexbox>
+ </Flexbox>
+ <ForwardModal open={modalOpen} onClose={() => setModalOpen(false)} />
+ </>
+ );
+});
+
+SelectionFooterBar.displayName = 'MessageForwardSelectionFooterBar';
+
+export default SelectionFooterBar;
diff --git a/src/features/Conversation/MessageForward/forwardDispatch.test.ts b/src/features/Conversation/MessageForward/forwardDispatch.test.ts
new file mode 100644
index 00000000000..916b68a7d7f
--- /dev/null
+++ b/src/features/Conversation/MessageForward/forwardDispatch.test.ts
@@ -0,0 +1,124 @@
+import { type UIChatMessage } from '@lobechat/types';
+import { describe, expect, it } from 'vitest';
+
+import { buildForwardedContent, canConsumePendingForward } from './forwardDispatch';
+import { type PendingForwardDispatch } from './forwardDispatch';
+
+const pending: PendingForwardDispatch = {
+ content: 'forwarded',
+ dispatchId: 'dispatch-1',
+ messageCount: 2,
+ targetAgentId: 'agent-1',
+};
+
+const roleLabel = (role: string) => (role === 'user' ? 'User' : 'Assistant');
+
+const msg = (over: Partial<UIChatMessage>): UIChatMessage =>
+ ({ id: 'm', role: 'user', ...over }) as UIChatMessage;
+
+describe('forwardDispatch', () => {
+ describe('canConsumePendingForward', () => {
+ it('allows once the target agent is active in a fresh topic', () => {
+ expect(
+ canConsumePendingForward({
+ agentId: 'agent-1',
+ isAgentConfigLoading: false,
+ pendingForward: pending,
+ routeAgentId: 'agent-1',
+ topicId: null,
+ }),
+ ).toBe(true);
+ });
+
+ it('blocks while the target agent already has a topic (not a new conversation)', () => {
+ expect(
+ canConsumePendingForward({
+ agentId: 'agent-1',
+ isAgentConfigLoading: false,
+ pendingForward: pending,
+ routeAgentId: 'agent-1',
+ topicId: 'topic-1',
+ }),
+ ).toBe(false);
+ });
+
+ it('blocks until the route switches to the target agent', () => {
+ expect(
+ canConsumePendingForward({
+ agentId: 'agent-2',
+ isAgentConfigLoading: false,
+ pendingForward: pending,
+ routeAgentId: 'agent-2',
+ topicId: null,
+ }),
+ ).toBe(false);
+ });
+
+ it('blocks while agent config is still loading', () => {
+ expect(
+ canConsumePendingForward({
+ agentId: 'agent-1',
+ isAgentConfigLoading: true,
+ pendingForward: pending,
+ routeAgentId: 'agent-1',
+ topicId: null,
+ }),
+ ).toBe(false);
+ });
+
+ it('blocks when there is no pending forward', () => {
+ expect(
+ canConsumePendingForward({
+ agentId: 'agent-1',
+ isAgentConfigLoading: false,
+ pendingForward: null,
+ routeAgentId: 'agent-1',
+ topicId: null,
+ }),
+ ).toBe(false);
+ });
+ });
+
+ describe('buildForwardedContent', () => {
+ it('renders a role-labelled transcript with a header', () => {
+ const content = buildForwardedContent(
+ [
+ msg({ content: 'hi there', role: 'user' }),
+ msg({ content: 'hello back', role: 'assistant' }),
+ ],
+ { header: 'Forwarded 2 messages:', roleLabel },
+ );
+
+ expect(content).toBe(
+ 'Forwarded 2 messages:\n\n---\n\n**User**\n\nhi there\n\n---\n\n**Assistant**\n\nhello back',
+ );
+ });
+
+ it('flattens assistantGroup child blocks into one block', () => {
+ const content = buildForwardedContent(
+ [
+ msg({
+ children: [
+ { content: 'part one' },
+ { content: 'part two' },
+ ] as UIChatMessage['children'],
+ content: '',
+ role: 'assistantGroup',
+ }),
+ ],
+ { header: 'H', roleLabel },
+ );
+
+ expect(content).toBe('H\n\n---\n\n**Assistant**\n\npart one\n\npart two');
+ });
+
+ it('skips messages with empty content', () => {
+ const content = buildForwardedContent(
+ [msg({ content: ' ', role: 'user' }), msg({ content: 'kept', role: 'assistant' })],
+ { header: 'H', roleLabel },
+ );
+
+ expect(content).toBe('H\n\n---\n\n**Assistant**\n\nkept');
+ });
+ });
+});
diff --git a/src/features/Conversation/MessageForward/forwardDispatch.ts b/src/features/Conversation/MessageForward/forwardDispatch.ts
new file mode 100644
index 00000000000..6c99d98533d
--- /dev/null
+++ b/src/features/Conversation/MessageForward/forwardDispatch.ts
@@ -0,0 +1,83 @@
+import { type UIChatMessage } from '@lobechat/types';
+
+/**
+ * A forward request parked in {@link useForwardDispatchStore} while we navigate
+ * to the target agent. Mirrors the screen-capture overlay-dispatch pattern: the
+ * payload can't ride a URL query param (a multi-message transcript is too big),
+ * so we stash it in a store and let a consumer mounted in the target agent's
+ * conversation drain it once that conversation is ready.
+ */
+export interface PendingForwardDispatch {
+ /** Already-formatted transcript that becomes the forwarded user message. */
+ content: string;
+ /** Distinguishes successive forwards so a stale consume can't fire twice. */
+ dispatchId: string;
+ /** How many messages the transcript was built from (for UX feedback). */
+ messageCount: number;
+ /** Agent the transcript is being forwarded to. */
+ targetAgentId: string;
+}
+
+interface CanConsumePendingForwardParams {
+ agentId?: string | null;
+ isAgentConfigLoading: boolean;
+ pendingForward: PendingForwardDispatch | null;
+ routeAgentId?: string | null;
+ topicId?: string | null;
+}
+
+/**
+ * Gate a pending forward against the conversation that's currently mounted, so
+ * we only send once the *target* agent's fresh conversation is the active one.
+ * Same guards as `canConsumePendingOverlayDispatch`.
+ */
+export const canConsumePendingForward = ({
+ agentId,
+ isAgentConfigLoading,
+ pendingForward,
+ routeAgentId,
+ topicId,
+}: CanConsumePendingForwardParams) => {
+ if (!pendingForward || !agentId) return false;
+ if (pendingForward.targetAgentId !== agentId) return false;
+ if (routeAgentId && routeAgentId !== agentId) return false;
+
+ // A forward always opens a brand-new topic on the target agent, so the topic
+ // must be unset. If it isn't yet (navigation still settling) we wait.
+ const isNewConversation = !topicId;
+
+ return !isAgentConfigLoading && isNewConversation;
+};
+
+const blockText = (label: string, body: string) => `**${label}**\n\n${body.trim()}`;
+
+/**
+ * Render selected messages into a single Markdown transcript. The result is sent
+ * as one user turn to the target agent, so it reads the forwarded exchange as
+ * context and continues from there.
+ */
+export const buildForwardedContent = (
+ messages: UIChatMessage[],
+ options: { header: string; roleLabel: (role: string) => string },
+): string => {
+ const { header, roleLabel } = options;
+
+ const blocks = messages
+ .map((message) => {
+ // AssistantGroup messages keep their text in child content blocks.
+ const body =
+ message.role === 'assistantGroup' && message.children?.length
+ ? message.children
+ .map((child) => child.content)
+ .filter(Boolean)
+ .join('\n\n')
+ : message.content;
+
+ if (!body || !body.trim()) return undefined;
+
+ return blockText(roleLabel(message.role), body);
+ })
+ .filter((block): block is string => !!block);
+
+ return [header, ...blocks].join('\n\n---\n\n');
+};
diff --git a/src/features/Conversation/MessageForward/forwardDispatchStore.ts b/src/features/Conversation/MessageForward/forwardDispatchStore.ts
new file mode 100644
index 00000000000..c7100a1be13
--- /dev/null
+++ b/src/features/Conversation/MessageForward/forwardDispatchStore.ts
@@ -0,0 +1,22 @@
+import { createWithEqualityFn } from 'zustand/traditional';
+
+import { type PendingForwardDispatch } from './forwardDispatch';
+
+interface ForwardDispatchStore {
+ clearPendingForward: (dispatchId?: string) => void;
+ pendingForward: PendingForwardDispatch | null;
+ setPendingForward: (pendingForward: PendingForwardDispatch) => void;
+}
+
+export const useForwardDispatchStore = createWithEqualityFn<ForwardDispatchStore>()((set) => ({
+ clearPendingForward: (dispatchId) =>
+ set((state) => {
+ if (dispatchId && state.pendingForward?.dispatchId !== dispatchId) return state;
+
+ return { pendingForward: null };
+ }),
+ pendingForward: null,
+ setPendingForward: (pendingForward) => set({ pendingForward }),
+}));
+
+export const getForwardDispatchStoreState = () => useForwardDispatchStore.getState();
diff --git a/src/features/Conversation/MessageForward/index.ts b/src/features/Conversation/MessageForward/index.ts
new file mode 100644
index 00000000000..a6fd3fb442c
--- /dev/null
+++ b/src/features/Conversation/MessageForward/index.ts
@@ -0,0 +1,3 @@
+export { default as ForwardMessageDispatcher } from './ForwardMessageDispatcher';
+export { default as MessageForwardFooter } from './MessageForwardFooter';
+export { default as MessageForwardSelectToHere } from './SelectToHereButton';
diff --git a/src/features/Conversation/MessageForward/selectableRoles.ts b/src/features/Conversation/MessageForward/selectableRoles.ts
new file mode 100644
index 00000000000..e343981cb9c
--- /dev/null
+++ b/src/features/Conversation/MessageForward/selectableRoles.ts
@@ -0,0 +1,8 @@
+/**
+ * Roles that carry forwardable text. Tool calls, tasks, verify cards etc. are
+ * not meaningful as standalone forwarded context, so they stay un-selectable.
+ * Shared by the per-message checkbox and the "select to here" range action.
+ */
+export const SELECTABLE_ROLES = new Set(['user', 'assistant', 'assistantGroup']);
+
+export const isSelectableRole = (role?: string): boolean => !!role && SELECTABLE_ROLES.has(role);
diff --git a/src/features/Conversation/MessageForward/useForwardMessages.ts b/src/features/Conversation/MessageForward/useForwardMessages.ts
new file mode 100644
index 00000000000..af3f9f2f637
--- /dev/null
+++ b/src/features/Conversation/MessageForward/useForwardMessages.ts
@@ -0,0 +1,92 @@
+import { nanoid } from '@lobechat/utils';
+import { App } from 'antd';
+import isEqual from 'fast-deep-equal';
+import { useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useNavigateToAgent } from '@/hooks/useNavigateToAgent';
+import { useChatStore } from '@/store/chat';
+
+import { useConversationStore } from '../store';
+import { buildForwardedContent } from './forwardDispatch';
+import { useForwardDispatchStore } from './forwardDispatchStore';
+
+export interface ForwardTarget {
+ id: string;
+ title?: string | null;
+}
+
+/**
+ * Returns a callback that forwards the currently-selected messages to one or
+ * more target agents. The transcript is serialised once, then:
+ * - the first (primary) target is parked + navigated to, so the user lands in
+ * it and {@link ForwardMessageDispatcher} sends the opening turn;
+ * - any additional targets are sent in the background via the global chat store
+ * (isolated new topic each), so "分别发送" reaches every recipient.
+ */
+export const useForwardMessages = () => {
+ const { t } = useTranslation('chat');
+ const { message } = App.useApp();
+ const navigateToAgent = useNavigateToAgent();
+ const setPendingForward = useForwardDispatchStore((s) => s.setPendingForward);
+ const exitSelectionMode = useConversationStore((s) => s.exitSelectionMode);
+
+ // The conversation store is context-scoped (no global getState), so read the
+ // selected messages reactively. They're frozen while the picker is open.
+ const selectedMessages = useConversationStore((s) => {
+ const selected = new Set(s.selectedMessageIds);
+ return s.displayMessages.filter((m) => selected.has(m.id));
+ }, isEqual);
+
+ return useCallback(
+ (targets: ForwardTarget[], note?: string) => {
+ if (selectedMessages.length === 0) {
+ message.warning(t('messageForward.empty'));
+ return;
+ }
+ if (targets.length === 0) return;
+
+ const transcript = buildForwardedContent(selectedMessages, {
+ header: t('messageForward.transcript.header', { count: selectedMessages.length }),
+ roleLabel: (role) =>
+ role === 'user' ? t('messageForward.role.user') : t('messageForward.role.assistant'),
+ });
+ // Append the user's optional note as the actual instruction after the
+ // forwarded context.
+ const content = note?.trim() ? `${transcript}\n\n${note.trim()}` : transcript;
+
+ const [primary, ...rest] = targets;
+
+ // Primary: park the transcript so the post-navigation dispatcher sends it.
+ setPendingForward({
+ content,
+ dispatchId: nanoid(),
+ messageCount: selectedMessages.length,
+ targetAgentId: primary.id,
+ });
+
+ // Additional recipients: fire-and-forget background sends into an isolated
+ // new topic each (no navigation, no hijacking the active topic).
+ for (const target of rest) {
+ void useChatStore
+ .getState()
+ .sendMessage({
+ context: { agentId: target.id, isNew: true, isolatedTopic: true, scope: 'main' },
+ message: content,
+ messages: [],
+ })
+ .catch(() => {});
+ }
+
+ exitSelectionMode();
+ navigateToAgent(primary.id);
+
+ message.success(
+ targets.length === 1
+ ? t('messageForward.success', { title: primary.title || '' })
+ : t('messageForward.successMulti', { count: targets.length }),
+ );
+ },
+ [t, message, navigateToAgent, setPendingForward, exitSelectionMode, selectedMessages],
+ );
+};
diff --git a/src/features/Conversation/Messages/Assistant/Actions/index.tsx b/src/features/Conversation/Messages/Assistant/Actions/index.tsx
index 6445f3ea436..e9b9f635861 100644
--- a/src/features/Conversation/Messages/Assistant/Actions/index.tsx
+++ b/src/features/Conversation/Messages/Assistant/Actions/index.tsx
@@ -22,6 +22,7 @@ const DEFAULT_MENU: MessageActionSlot[] = [
'translate',
'divider',
'share',
+ 'select',
'divider',
'regenerate',
'delAndRegenerate',
diff --git a/src/features/Conversation/Messages/AssistantGroup/Actions/index.tsx b/src/features/Conversation/Messages/AssistantGroup/Actions/index.tsx
index 59507293ba1..ac84c501860 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Actions/index.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Actions/index.tsx
@@ -19,6 +19,7 @@ const DEFAULT_MENU: MessageActionSlot[] = [
'collapse',
'divider',
'share',
+ 'select',
'divider',
'regenerate',
'del',
diff --git a/src/features/Conversation/Messages/Contexts/MessageActionProvider.tsx b/src/features/Conversation/Messages/Contexts/MessageActionProvider.tsx
index abb8ed4b34b..645493d6e96 100644
--- a/src/features/Conversation/Messages/Contexts/MessageActionProvider.tsx
+++ b/src/features/Conversation/Messages/Contexts/MessageActionProvider.tsx
@@ -5,7 +5,7 @@ import { createPortal } from 'react-dom';
import { MESSAGE_ACTION_BAR_PORTAL_SELECTORS } from '@/const/messageActionPortal';
-import { dataSelectors, useConversationStore } from '../../store';
+import { dataSelectors, messageStateSelectors, useConversationStore } from '../../store';
import { AssistantActionsBar } from '../Assistant/Actions';
import { GroupActionsBar } from '../AssistantGroup/Actions';
import { UserActionsBar } from '../User/Actions';
@@ -68,6 +68,9 @@ const AssistantGroupActionsRenderer: FC<SingletonPortalProps> = ({ id }) => {
const SingletonMessageActionsBar = memo(() => {
const livePortalElement = useMessageItemActionElementPortialContext();
const liveActionType = useMessageItemActionTypeContext();
+ // While multi-selecting, the per-message hover action bar would compete with
+ // the selection checkboxes/overlay — suppress it entirely.
+ const isSelectionMode = useConversationStore(messageStateSelectors.isSelectionMode);
const hostRef = useRef<HTMLDivElement | null>(null);
if (!hostRef.current && typeof document !== 'undefined') {
@@ -171,7 +174,7 @@ const SingletonMessageActionsBar = memo(() => {
}, []);
const hostEl = hostRef.current;
- if (!hostEl || !committedActionType) return null;
+ if (!hostEl || !committedActionType || isSelectionMode) return null;
switch (committedActionType.type) {
case 'assistant': {
diff --git a/src/features/Conversation/Messages/User/Actions/index.tsx b/src/features/Conversation/Messages/User/Actions/index.tsx
index d0e523b7a99..5b8fa86278e 100644
--- a/src/features/Conversation/Messages/User/Actions/index.tsx
+++ b/src/features/Conversation/Messages/User/Actions/index.tsx
@@ -23,6 +23,8 @@ const DEFAULT_MENU: MessageActionSlot[] = [
'tts',
'translate',
'divider',
+ 'select',
+ 'divider',
'regenerate',
'del',
];
diff --git a/src/features/Conversation/Messages/components/MessageActionBar/actions/select.ts b/src/features/Conversation/Messages/components/MessageActionBar/actions/select.ts
new file mode 100644
index 00000000000..00e6a75f00f
--- /dev/null
+++ b/src/features/Conversation/Messages/components/MessageActionBar/actions/select.ts
@@ -0,0 +1,30 @@
+import { ListChecks } from 'lucide-react';
+import { useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useConversationStore } from '../../../../store';
+import { defineAction } from '../defineAction';
+
+/**
+ * Enters multi-select mode with the current message pre-checked, so the user can
+ * keep checking more messages and forward the batch to another agent.
+ */
+export const selectAction = defineAction({
+ key: 'select',
+ useBuild: (ctx) => {
+ const { t } = useTranslation('chat');
+ const enterSelectionMode = useConversationStore((s) => s.enterSelectionMode);
+
+ return useMemo(
+ () => ({
+ handleClick: () => {
+ enterSelectionMode(ctx.id);
+ },
+ icon: ListChecks,
+ key: 'select',
+ label: t('messageAction.select'),
+ }),
+ [t, ctx.id, enterSelectionMode],
+ );
+ },
+});
diff --git a/src/features/Conversation/Messages/components/MessageActionBar/useBuildActions.ts b/src/features/Conversation/Messages/components/MessageActionBar/useBuildActions.ts
index 0a970c66c77..98f13b065ca 100644
--- a/src/features/Conversation/Messages/components/MessageActionBar/useBuildActions.ts
+++ b/src/features/Conversation/Messages/components/MessageActionBar/useBuildActions.ts
@@ -7,6 +7,7 @@ import { delAction } from './actions/del';
import { delAndRegenerateAction } from './actions/delAndRegenerate';
import { editAction } from './actions/edit';
import { regenerateAction } from './actions/regenerate';
+import { selectAction } from './actions/select';
import { shareAction } from './actions/share';
import { translateAction } from './actions/translate';
import { ttsAction } from './actions/tts';
@@ -32,6 +33,7 @@ export const useBuildActions = (
delAndRegenerate: delAndRegenerateAction.useBuild(ctx),
edit: editAction.useBuild(ctx),
regenerate: regenerateAction.useBuild(ctx),
+ select: selectAction.useBuild(ctx),
share: shareAction.useBuild(ctx),
translate: translateAction.useBuild(ctx),
tts: ttsAction.useBuild(ctx),
diff --git a/src/features/Conversation/Messages/index.tsx b/src/features/Conversation/Messages/index.tsx
index c9c3283dfae..6e104a218a9 100644
--- a/src/features/Conversation/Messages/index.tsx
+++ b/src/features/Conversation/Messages/index.tsx
@@ -12,6 +12,7 @@ import SafeBoundary from '@/components/ErrorBoundary';
import History from '../components/History';
import { useChatItemContextMenu } from '../hooks/useChatItemContextMenu';
+import MessageSelectionWrapper from '../MessageForward/MessageSelectionWrapper';
import { dataSelectors, messageStateSelectors, useConversationStore } from '../store';
import AgentCouncilMessage from './AgentCouncil';
import AssistantMessage from './Assistant';
@@ -220,9 +221,11 @@ const MessageItem = memo<MessageItemProps>(
data-index={index}
onContextMenu={onContextMenu}
>
- <SafeBoundary variant="alert">
- <Suspense fallback={<BubblesLoading />}>{renderContent()}</Suspense>
- </SafeBoundary>
+ <MessageSelectionWrapper id={id} role={role}>
+ <SafeBoundary variant="alert">
+ <Suspense fallback={<BubblesLoading />}>{renderContent()}</Suspense>
+ </SafeBoundary>
+ </MessageSelectionWrapper>
{!shouldInjectFooter && footerRender}
{endRender}
</Flexbox>
diff --git a/src/features/Conversation/store/selectors.test.ts b/src/features/Conversation/store/selectors.test.ts
index 1ee4e03296d..559f938072b 100644
--- a/src/features/Conversation/store/selectors.test.ts
+++ b/src/features/Conversation/store/selectors.test.ts
@@ -17,6 +17,8 @@ const createMockState = (overrides: Partial<State> = {}): State => ({
messageEditingIds: [],
messageLoadingIds: [],
pendingArgsUpdates: new Map(),
+ selectedMessageIds: [],
+ selectionMode: false,
// VirtuaList state
activeIndex: null,
diff --git a/src/features/Conversation/store/slices/messageState/action.ts b/src/features/Conversation/store/slices/messageState/action.ts
index 570adfcd98d..ebc0d92e0fe 100644
--- a/src/features/Conversation/store/slices/messageState/action.ts
+++ b/src/features/Conversation/store/slices/messageState/action.ts
@@ -1,13 +1,33 @@
import { produce } from 'immer';
import { type StateCreator } from 'zustand';
+import { isSelectableRole } from '../../../MessageForward/selectableRoles';
import { type State } from '../../initialState';
export interface MessageEditingAction {
+ /**
+ * Enter multi-select mode. When `initialId` is provided that message starts
+ * selected and anchors the "select to here" range action.
+ */
+ enterSelectionMode: (initialId?: string) => void;
+ /**
+ * Leave multi-select mode and drop every selected id.
+ */
+ exitSelectionMode: () => void;
+ /**
+ * Select every selectable message from the top of the conversation down to
+ * the anchor (the message selection started from), inclusive. Mirrors
+ * WeChat's "选择到这里".
+ */
+ selectToHere: () => void;
/**
* Toggle message editing state
*/
toggleMessageEditing: (id: string, editing: boolean) => void;
+ /**
+ * Toggle whether a message is checked in multi-select mode.
+ */
+ toggleMessageSelected: (id: string, selected?: boolean) => void;
}
/**
@@ -30,6 +50,38 @@ export const messageEditingSlice: StateCreator<
[],
MessageEditingAction
> = (set, get) => ({
+ enterSelectionMode: (initialId) => {
+ set(
+ {
+ selectedMessageIds: initialId ? [initialId] : [],
+ selectionAnchorId: initialId,
+ selectionMode: true,
+ },
+ false,
+ 'enterSelectionMode',
+ );
+ },
+ exitSelectionMode: () => {
+ set(
+ { selectedMessageIds: [], selectionAnchorId: undefined, selectionMode: false },
+ false,
+ 'exitSelectionMode',
+ );
+ },
+ selectToHere: () => {
+ const { displayMessages, selectionAnchorId } = get();
+ const anchorIndex = selectionAnchorId
+ ? displayMessages.findIndex((m) => m.id === selectionAnchorId)
+ : displayMessages.length - 1;
+ if (anchorIndex < 0) return;
+
+ const ids = displayMessages
+ .slice(0, anchorIndex + 1)
+ .filter((m) => isSelectableRole(m.role))
+ .map((m) => m.id);
+
+ set({ selectedMessageIds: ids }, false, 'selectToHere');
+ },
toggleMessageEditing: (id, editing) => {
set(
{ messageEditingIds: toggleBooleanList(get().messageEditingIds, id, editing) },
@@ -37,4 +89,13 @@ export const messageEditingSlice: StateCreator<
'toggleMessageEditing',
);
},
+ toggleMessageSelected: (id, selected) => {
+ const current = get().selectedMessageIds;
+ const next = selected ?? !current.includes(id);
+ set(
+ { selectedMessageIds: toggleBooleanList(current, id, next) },
+ false,
+ 'toggleMessageSelected',
+ );
+ },
});
diff --git a/src/features/Conversation/store/slices/messageState/initialState.ts b/src/features/Conversation/store/slices/messageState/initialState.ts
index c5bbcb3005d..bc3be6ffd9a 100644
--- a/src/features/Conversation/store/slices/messageState/initialState.ts
+++ b/src/features/Conversation/store/slices/messageState/initialState.ts
@@ -33,6 +33,25 @@ export interface MessageStateState {
* Used to ensure approve/reject waits for pending saves to complete
*/
pendingArgsUpdates: Map<string, Promise<void>>;
+
+ /**
+ * IDs of messages currently checked in multi-select mode. Only meaningful
+ * while `selectionMode` is true; cleared on exit.
+ */
+ selectedMessageIds: string[];
+
+ /**
+ * The message multi-select mode was entered from. Anchors the "select to
+ * here" range action (top-of-conversation → anchor).
+ */
+ selectionAnchorId?: string;
+
+ /**
+ * Whether the conversation is in multi-select mode (used to forward several
+ * messages to another agent). When true, each message renders a checkbox and
+ * the per-message action bar is suppressed.
+ */
+ selectionMode: boolean;
}
export const messageStateInitialState: MessageStateState = {
@@ -41,4 +60,7 @@ export const messageStateInitialState: MessageStateState = {
messageEditingIds: [],
messageLoadingIds: [],
pendingArgsUpdates: new Map(),
+ selectionAnchorId: undefined,
+ selectedMessageIds: [],
+ selectionMode: false,
};
diff --git a/src/features/Conversation/store/slices/messageState/selectors.ts b/src/features/Conversation/store/slices/messageState/selectors.ts
index 2e4695c1495..d0dde06a76a 100644
--- a/src/features/Conversation/store/slices/messageState/selectors.ts
+++ b/src/features/Conversation/store/slices/messageState/selectors.ts
@@ -32,6 +32,23 @@ const messageEditingIds = (s: State) => s.messageEditingIds;
*/
const messageLoadingIds = (s: State) => s.messageLoadingIds;
+// ===== Multi-select selectors =====
+
+/**
+ * Whether the conversation is in multi-select mode
+ */
+const isSelectionMode = (s: State) => s.selectionMode;
+
+/**
+ * Whether a given message is checked in multi-select mode
+ */
+const isMessageSelected = (id: string) => (s: State) => s.selectedMessageIds.includes(id);
+
+/**
+ * Number of checked messages
+ */
+const selectedMessageCount = (s: State) => s.selectedMessageIds.length;
+
// ===== Operation-based selectors (read from external operationState) =====
// Note: These selectors read from operationState which is passed externally from ChatStore.
// This ensures proper React reactivity while keeping operations global.
@@ -182,11 +199,14 @@ export const messageStateSelectors = {
isMessageLoading,
isMessageProcessing,
isMessageRegenerating,
+ isMessageSelected,
isPluginApiInvoking,
+ isSelectionMode,
isThreadMode,
isToolApiNameShining,
isToolCallStreaming,
messageEditingIds,
messageLoadingIds,
+ selectedMessageCount,
sendMessageError,
};
diff --git a/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx b/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx
index d6108f5659c..6bb483999d2 100644
--- a/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx
+++ b/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx
@@ -10,6 +10,10 @@ import AgentHome from '@/features/AgentHome';
import ChatMiniMap from '@/features/ChatMiniMap';
import { ChatList, ConversationProvider } from '@/features/Conversation';
import { useChatFollowUp } from '@/features/Conversation/hooks/useChatFollowUp';
+import {
+ ForwardMessageDispatcher,
+ MessageForwardFooter,
+} from '@/features/Conversation/MessageForward';
import { mergeConversationHooks } from '@/features/Conversation/utils/mergeConversationHooks';
import { useGatewayReconnect } from '@/hooks/useGatewayReconnect';
import { useOperationState } from '@/hooks/useOperationState';
@@ -131,9 +135,14 @@ const Conversation = memo(() => {
}
/>
</Flexbox>
- {!isSubagentThread && (isHeterogeneousAgent ? <HeterogeneousChatInput /> : <MainChatInput />)}
+ {!isSubagentThread && (
+ <MessageForwardFooter>
+ {isHeterogeneousAgent ? <HeterogeneousChatInput /> : <MainChatInput />}
+ </MessageForwardFooter>
+ )}
<ThreadHydration />
<ChatMiniMap />
+ <ForwardMessageDispatcher />
<Suspense>
<MessageFromUrl />
</Suspense>
diff --git a/src/routes/(main)/group/features/Conversation/ConversationArea.tsx b/src/routes/(main)/group/features/Conversation/ConversationArea.tsx
index d100f176a01..9fd6cb8984e 100644
--- a/src/routes/(main)/group/features/Conversation/ConversationArea.tsx
+++ b/src/routes/(main)/group/features/Conversation/ConversationArea.tsx
@@ -5,6 +5,10 @@ import { memo, Suspense, useMemo } from 'react';
import ChatMiniMap from '@/features/ChatMiniMap';
import { ChatList, ConversationProvider } from '@/features/Conversation';
+import {
+ ForwardMessageDispatcher,
+ MessageForwardFooter,
+} from '@/features/Conversation/MessageForward';
import { useOperationState } from '@/hooks/useOperationState';
import { useChatStore } from '@/store/chat';
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
@@ -66,9 +70,12 @@ const Conversation = memo<ConversationAreaProps>(({ mobile = false }) => {
>
<ChatList welcome={<WelcomeChatItem />} />
</Flexbox>
- <MainChatInput />
+ <MessageForwardFooter>
+ <MainChatInput />
+ </MessageForwardFooter>
<ChatHydration />
<ThreadHydration />
+ <ForwardMessageDispatcher />
{!mobile && (
<>
<ChatMiniMap />