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.

💄 style(hetero-agent): read-only SubAgent threads with breadcrumb header and thread switcher (#14658)

Arvin Xu31e9130cf02d
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index be8ff6cff49..55d2002a0dc 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -653,10 +653,11 @@
"taskSchedule.weekdays.thu": "Thu",
"taskSchedule.weekdays.tue": "Tue",
"taskSchedule.weekdays.wed": "Wed",
- "thread.closeSubagentThread": "Collapse subagent conversation",
+ "thread.closeSubagentThread": "Collapse SubAgent conversation",
"thread.divider": "Subtopic",
- "thread.openSubagentThread": "View full subagent conversation",
- "thread.subagentBadge": "Subagent",
+ "thread.openSubagentThread": "View full SubAgent conversation",
+ "thread.subagentBadge": "SubAgent",
+ "thread.subagentReadOnlyHint": "SubAgent conversations are read-only — execution is driven by the parent agent.",
"thread.threadMessageCount": "{{messageCount}} messages",
"thread.title": "Subtopic",
"todoProgress.allCompleted": "All tasks completed",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 647dd464e05..d0203f5ba1c 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -653,10 +653,11 @@
"taskSchedule.weekdays.thu": "四",
"taskSchedule.weekdays.tue": "二",
"taskSchedule.weekdays.wed": "三",
- "thread.closeSubagentThread": "收起子智能体对话",
+ "thread.closeSubagentThread": "收起 SubAgent 对话",
"thread.divider": "子话题",
- "thread.openSubagentThread": "查看完整子智能体对话",
- "thread.subagentBadge": "子智能体",
+ "thread.openSubagentThread": "查看完整 SubAgent 对话",
+ "thread.subagentBadge": "SubAgent",
+ "thread.subagentReadOnlyHint": "SubAgent 对话仅可查看,由父智能体驱动执行",
"thread.threadMessageCount": "{{messageCount}} 条消息",
"thread.title": "子话题",
"todoProgress.allCompleted": "已完成所有任务",
diff --git a/src/features/Conversation/ChatInput/QueueTray.tsx b/src/features/Conversation/ChatInput/QueueTray.tsx
index b0464165f7c..bae55143468 100644
--- a/src/features/Conversation/ChatInput/QueueTray.tsx
+++ b/src/features/Conversation/ChatInput/QueueTray.tsx
@@ -37,7 +37,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
height: 28px;
padding-block: 0;
padding-inline: 6px;
- border: 1px solid ${cssVar.colorBorderSecondary};
+ border: 1px solid ${cssVar.colorFillTertiary};
border-radius: 6px;
font-size: 12px;
@@ -58,7 +58,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
width: 28px !important;
height: 28px !important;
margin-block: 0 !important;
- border: 1px solid ${cssVar.colorBorderSecondary};
+ border: 1px solid ${cssVar.colorFillTertiary};
border-radius: 6px;
box-shadow: none;
diff --git a/src/features/Conversation/ChatList/components/VirtualizedList.tsx b/src/features/Conversation/ChatList/components/VirtualizedList.tsx
index 9e1e6c4e191..12680dab7b7 100644
--- a/src/features/Conversation/ChatList/components/VirtualizedList.tsx
+++ b/src/features/Conversation/ChatList/components/VirtualizedList.tsx
@@ -29,8 +29,11 @@ import DebugInspector, { OPEN_DEV_INSPECTOR } from './AutoScroll/DebugInspector'
import { useAutoScrollEnabled } from './AutoScroll/useAutoScrollEnabled';
import BackBottom from './BackBottom';
+const CONVERSATION_FOOTER_ID = '__conversation_footer__';
+
interface VirtualizedListProps {
dataSource: string[];
+ footerSlot?: ReactNode;
itemContent: (index: number, data: string) => ReactNode;
}
@@ -39,7 +42,7 @@ interface VirtualizedListProps {
*
* Based on ConversationStore data flow, no dependency on global ChatStore.
*/
-const VirtualizedList = memo<VirtualizedListProps>(({ dataSource, itemContent }) => {
+const VirtualizedList = memo<VirtualizedListProps>(({ dataSource, footerSlot, itemContent }) => {
const virtuaRef = useRef<VListHandle>(null);
const scrollEndTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -145,6 +148,7 @@ const VirtualizedList = memo<VirtualizedListProps>(({ dataSource, itemContent })
getItemSize: (index) => ref.getItemSize(index),
getScrollOffset: () => ref.scrollOffset,
getScrollSize: () => ref.scrollSize,
+ getTotalCount: () => totalCountRef.current,
getViewportSize: () => ref.viewportSize,
scrollTo: (offset) => ref.scrollTo(offset),
scrollToIndex: (index, options) => ref.scrollToIndex(index, options),
@@ -213,13 +217,24 @@ const VirtualizedList = memo<VirtualizedListProps>(({ dataSource, itemContent })
const overlayHeight = useConversationStore(inputSelectors.chatInputOverlayHeight);
const paddingBottom = Math.max(24, overlayHeight + 12);
+ const dataWithFooter = useMemo(
+ () => (footerSlot ? [...listData, CONVERSATION_FOOTER_ID] : listData),
+ [listData, footerSlot],
+ );
+
+ // Mirror the latest data length into a ref so the scroll-methods registered
+ // once on mount can read the current total count (including spacer/footer)
+ // without re-registering on every render.
+ const totalCountRef = useRef(dataWithFooter.length);
+ totalCountRef.current = dataWithFooter.length;
+
return (
<div style={{ height: '100%', position: 'relative' }}>
{/* Debug Inspector - placed outside VList so it won't be recycled by the virtual list */}
{OPEN_DEV_INSPECTOR && <DebugInspector />}
<VList
bufferSize={typeof window !== 'undefined' ? window.innerHeight : 0}
- data={listData}
+ data={dataWithFooter}
keepMounted={keepMountedIndices}
ref={virtuaRef}
style={{ height: '100%', overflowAnchor: 'none', paddingBottom }}
@@ -227,6 +242,13 @@ const VirtualizedList = memo<VirtualizedListProps>(({ dataSource, itemContent })
onScrollEnd={handleScrollEnd}
>
{(messageId, index): ReactElement => {
+ if (messageId === CONVERSATION_FOOTER_ID) {
+ return (
+ <WideScreenContainer key={messageId} style={{ position: 'relative' }}>
+ {footerSlot}
+ </WideScreenContainer>
+ );
+ }
if (isSpacerMessage(messageId)) {
// Only animate the collapse-to-zero (unmount). Any non-zero height
// change (initial mount, shrink as assistant grows) is applied
diff --git a/src/features/Conversation/ChatList/index.tsx b/src/features/Conversation/ChatList/index.tsx
index 2bae5130a9c..bfe80979164 100644
--- a/src/features/Conversation/ChatList/index.tsx
+++ b/src/features/Conversation/ChatList/index.tsx
@@ -37,6 +37,12 @@ export interface ChatListProps {
* Disable the actions bar for all messages (e.g., in share page)
*/
disableActionsBar?: boolean;
+ /**
+ * Optional content rendered as the last item inside the virtualized list —
+ * scrolls with the messages instead of being pinned to the viewport bottom.
+ * Used e.g. for the SubAgent read-only hint after the last message.
+ */
+ footerSlot?: ReactNode;
/**
* Custom item renderer. If not provided, uses default ChatItem.
*/
@@ -56,7 +62,14 @@ export interface ChatListProps {
* Uses ConversationStore for message data and fetching.
*/
const ChatList = memo<ChatListProps>(
- ({ defaultWorkflowExpandLevel, disableActionsBar, welcome, itemContent, showWelcome }) => {
+ ({
+ defaultWorkflowExpandLevel,
+ disableActionsBar,
+ footerSlot,
+ welcome,
+ itemContent,
+ showWelcome,
+ }) => {
// Fetch messages (SWR key is null when skipFetch is true)
const context = useConversationStore((s) => s.context);
const enableUserMemories = useUserStore(settingsSelectors.memoryEnabled);
@@ -143,6 +156,7 @@ const ChatList = memo<ChatListProps>(
<MessageActionProvider withSingletonActionsBar={!disableActionsBar}>
<VirtualizedList
dataSource={displayMessageIds}
+ footerSlot={footerSlot}
itemContent={itemContent ?? defaultItemContent}
/>
</MessageActionProvider>
diff --git a/src/features/Conversation/store/slices/virtuaList/action.ts b/src/features/Conversation/store/slices/virtuaList/action.ts
index 39597632ff2..3db851bc5fe 100644
--- a/src/features/Conversation/store/slices/virtuaList/action.ts
+++ b/src/features/Conversation/store/slices/virtuaList/action.ts
@@ -100,8 +100,15 @@ export const virtuaListSlice: StateCreator<State & VirtuaListAction, [], [], Vir
scrollToBottom: (smooth = true) => {
const { displayMessages, virtuaScrollMethods } = get();
if (displayMessages.length === 0) return;
+ if (!virtuaScrollMethods) return;
- virtuaScrollMethods?.scrollToIndex(displayMessages.length - 1, {
+ // Target the true last item rather than the last message — VList may
+ // append trailing items (spacer, SubAgent footer hint) that would
+ // otherwise be left below the viewport and keep atBottom = false.
+ const totalCount = virtuaScrollMethods.getTotalCount();
+ const targetIndex = Math.max(totalCount - 1, displayMessages.length - 1);
+
+ virtuaScrollMethods.scrollToIndex(targetIndex, {
align: 'end',
smooth,
});
diff --git a/src/features/Conversation/store/slices/virtuaList/initialState.ts b/src/features/Conversation/store/slices/virtuaList/initialState.ts
index 534e4843c74..29e3a1ad589 100644
--- a/src/features/Conversation/store/slices/virtuaList/initialState.ts
+++ b/src/features/Conversation/store/slices/virtuaList/initialState.ts
@@ -6,6 +6,13 @@ export interface VirtuaScrollMethods {
getItemSize: (index: number) => number;
getScrollOffset: () => number;
getScrollSize: () => number;
+ /**
+ * Total number of items currently rendered by VList, including trailing
+ * synthetic items (spacer, footerSlot) that are not part of displayMessages.
+ * Used by scrollToBottom to land on the true last index instead of the last
+ * message, which would otherwise leave trailing items below the viewport.
+ */
+ getTotalCount: () => number;
getViewportSize: () => number;
scrollTo: (offset: number) => void;
scrollToIndex: (
diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.ts
index 67bf18e4d84..43a5ddefab2 100644
--- a/src/locales/default/chat.ts
+++ b/src/locales/default/chat.ts
@@ -707,10 +707,12 @@ export default {
'taskList.view.board': 'Board',
'taskList.view.list': 'List',
'taskList.viewAll': 'View all',
- 'thread.closeSubagentThread': 'Collapse subagent conversation',
+ 'thread.closeSubagentThread': 'Collapse SubAgent conversation',
'thread.divider': 'Subtopic',
- 'thread.openSubagentThread': 'View full subagent conversation',
- 'thread.subagentBadge': 'Subagent',
+ 'thread.openSubagentThread': 'View full SubAgent conversation',
+ 'thread.subagentBadge': 'SubAgent',
+ 'thread.subagentReadOnlyHint':
+ 'SubAgent conversations are read-only — execution is driven by the parent agent.',
'thread.threadMessageCount': '{{messageCount}} messages',
'thread.title': 'Subtopic',
'todoProgress.allCompleted': 'All tasks completed',
diff --git a/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx b/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx
index 80792fb7d3d..5f52455af13 100644
--- a/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx
+++ b/src/routes/(main)/agent/features/Conversation/ConversationArea.tsx
@@ -1,8 +1,10 @@
'use client';
import { Flexbox } from '@lobehub/ui';
+import { cssVar } from 'antd-style';
import debug from 'debug';
import { memo, Suspense, useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
import AgentHome from '@/features/AgentHome';
import ChatMiniMap from '@/features/ChatMiniMap';
@@ -13,7 +15,7 @@ import { useOperationState } from '@/hooks/useOperationState';
import { useAgentStore } from '@/store/agent';
import { agentSelectors } from '@/store/agent/selectors';
import { useChatStore } from '@/store/chat';
-import { topicSelectors } from '@/store/chat/selectors';
+import { threadSelectors, topicSelectors } from '@/store/chat/selectors';
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
import HeterogeneousChatInput from './HeterogeneousChatInput';
@@ -32,6 +34,7 @@ const log = debug('lobe-render:agent:ConversationArea');
* Uses ChatList from @/features/Conversation and MainChatInput for custom features.
*/
const Conversation = memo(() => {
+ const { t } = useTranslation('chat');
const context = useAgentContext();
// Get raw dbMessages from ChatStore for this context
@@ -56,6 +59,10 @@ const Conversation = memo(() => {
// model/tools/memory/KB/MCP/runtime-mode pickers don't apply.
const isHeterogeneousAgent = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);
+ // Subagent threads (spawned by an external agent's subagent tool call) are
+ // read-only — the parent agent drives their execution, so hide the input.
+ const isSubagentThread = useChatStore(threadSelectors.isActiveThreadSubagent);
+
// Auto-reconnect to running Gateway operation on topic load
const runningOperation = useChatStore((s) =>
context.topicId
@@ -88,9 +95,30 @@ const Conversation = memo(() => {
<ChatList
defaultWorkflowExpandLevel={isHeterogeneousAgent ? { streaming: 'full' } : undefined}
welcome={<AgentHome />}
+ footerSlot={
+ isSubagentThread ? (
+ <Flexbox
+ horizontal
+ align={'center'}
+ justify={'center'}
+ paddingBlock={6}
+ paddingInline={16}
+ >
+ <span
+ style={{
+ color: cssVar.colorTextDescription,
+ fontSize: 12,
+ textAlign: 'center',
+ }}
+ >
+ {t('thread.subagentReadOnlyHint')}
+ </span>
+ </Flexbox>
+ ) : undefined
+ }
/>
</Flexbox>
- {isHeterogeneousAgent ? <HeterogeneousChatInput /> : <MainChatInput />}
+ {!isSubagentThread && (isHeterogeneousAgent ? <HeterogeneousChatInput /> : <MainChatInput />)}
<ThreadHydration />
<ChatMiniMap />
<Suspense>
diff --git a/src/routes/(main)/agent/features/Conversation/Header/Tags/ThreadSwitcher.tsx b/src/routes/(main)/agent/features/Conversation/Header/Tags/ThreadSwitcher.tsx
new file mode 100644
index 00000000000..cdbc0e963b0
--- /dev/null
+++ b/src/routes/(main)/agent/features/Conversation/Header/Tags/ThreadSwitcher.tsx
@@ -0,0 +1,133 @@
+'use client';
+
+import { Flexbox, Popover } from '@lobehub/ui';
+import { createStaticStyles, cx } from 'antd-style';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useChatStore } from '@/store/chat';
+import { threadSelectors } from '@/store/chat/selectors';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ item: css`
+ cursor: pointer;
+
+ overflow: hidden;
+
+ padding-block: 6px;
+ padding-inline: 10px;
+ border-radius: 6px;
+
+ font-size: 13px;
+ color: ${cssVar.colorText};
+ text-overflow: ellipsis;
+ white-space: nowrap;
+
+ transition: background 0.15s;
+
+ &:hover {
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+ itemActive: css`
+ font-weight: 600;
+ background: ${cssVar.colorFillSecondary};
+
+ &:hover {
+ background: ${cssVar.colorFillSecondary};
+ }
+ `,
+ trigger: css`
+ cursor: pointer;
+
+ overflow: hidden;
+ display: inline-block;
+
+ min-width: 0;
+ padding-block: 2px;
+ padding-inline: 6px;
+ border: none;
+ border-radius: 6px;
+
+ font-size: 14px;
+ font-weight: 600;
+ line-height: 1.5;
+ color: ${cssVar.colorText};
+ text-overflow: ellipsis;
+ white-space: nowrap;
+
+ background: transparent;
+ outline: none;
+
+ transition: background 0.15s;
+
+ &:hover {
+ background: ${cssVar.colorFillTertiary};
+ }
+
+ &:focus,
+ &:focus-visible {
+ outline: none;
+ box-shadow: none;
+ }
+
+ &[data-popup-open] {
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+}));
+
+interface ThreadSwitcherProps {
+ title: string;
+}
+
+const ThreadSwitcher = memo<ThreadSwitcherProps>(({ title }) => {
+ const { t } = useTranslation('chat');
+ const activeThreadId = useChatStore((s) => s.activeThreadId);
+ const threads = useChatStore(threadSelectors.currentTopicThreads);
+ const switchThread = useChatStore((s) => s.switchThread);
+
+ const handleSwitch = (id: string) => {
+ if (id === activeThreadId) return;
+ void switchThread(id);
+ };
+
+ const content = (
+ <Flexbox
+ gap={2}
+ padding={4}
+ style={{
+ maxHeight: '50vh',
+ maxWidth: 360,
+ minWidth: 240,
+ overflowY: 'auto',
+ }}
+ >
+ {threads.map((thread) => (
+ <div
+ className={cx(styles.item, thread.id === activeThreadId && styles.itemActive)}
+ key={thread.id}
+ onClick={() => handleSwitch(thread.id)}
+ >
+ {thread.title || t('thread.title')}
+ </div>
+ ))}
+ </Flexbox>
+ );
+
+ return (
+ <Popover
+ arrow={false}
+ classNames={{ trigger: styles.trigger }}
+ content={content}
+ nativeButton={false}
+ placement={'bottomLeft'}
+ styles={{ content: { padding: 4 } }}
+ trigger={'click'}
+ >
+ {title}
+ </Popover>
+ );
+});
+
+export default ThreadSwitcher;
diff --git a/src/routes/(main)/agent/features/Conversation/Header/Tags/index.tsx b/src/routes/(main)/agent/features/Conversation/Header/Tags/index.tsx
index 00245275af8..27ba9a5fa18 100644
--- a/src/routes/(main)/agent/features/Conversation/Header/Tags/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/Header/Tags/index.tsx
@@ -10,6 +10,7 @@ import { sessionSelectors } from '@/store/session/selectors';
import FolderTag from './FolderTag';
import MemberCountTag from './MemberCountTag';
+import ThreadSwitcher from './ThreadSwitcher';
const TitleTags = memo(() => {
const { t } = useTranslation(['topic', 'chat']);
@@ -30,27 +31,56 @@ const TitleTags = memo(() => {
);
}
- const displayTitle = activeThreadId
- ? threadTitle || t('thread.title', { ns: 'chat' })
- : topicTitle || t('newTopic');
+ const fallbackTopicTitle = topicTitle || t('newTopic');
+ const fallbackThreadTitle = threadTitle || t('thread.title', { ns: 'chat' });
return (
- <Flexbox allowShrink horizontal align={'center'} gap={8}>
- <span
- style={{
- color: cssVar.colorText,
- fontSize: 14,
- fontWeight: 600,
- marginLeft: 8,
- minWidth: 0,
- overflow: 'hidden',
- textOverflow: 'ellipsis',
- whiteSpace: 'nowrap',
- }}
- >
- {displayTitle}
- </span>
- <FolderTag />
+ <Flexbox allowShrink horizontal align={'center'} gap={6} style={{ marginLeft: 8, minWidth: 0 }}>
+ {activeThreadId ? (
+ <>
+ <span
+ style={{
+ color: cssVar.colorTextSecondary,
+ flexShrink: 0,
+ fontSize: 14,
+ fontWeight: 500,
+ maxWidth: 200,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ }}
+ >
+ {fallbackTopicTitle}
+ </span>
+ <span
+ style={{
+ color: cssVar.colorTextQuaternary,
+ flexShrink: 0,
+ fontSize: 14,
+ }}
+ >
+ {'/'}
+ </span>
+ <ThreadSwitcher title={fallbackThreadTitle} />
+ </>
+ ) : (
+ <>
+ <span
+ style={{
+ color: cssVar.colorText,
+ fontSize: 14,
+ fontWeight: 600,
+ minWidth: 0,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ }}
+ >
+ {fallbackTopicTitle}
+ </span>
+ <FolderTag />
+ </>
+ )}
</Flexbox>
);
});
diff --git a/src/store/chat/slices/thread/selectors/index.ts b/src/store/chat/slices/thread/selectors/index.ts
index a5378d0e494..7e8bfdfba3a 100644
--- a/src/store/chat/slices/thread/selectors/index.ts
+++ b/src/store/chat/slices/thread/selectors/index.ts
@@ -24,6 +24,19 @@ const currentPortalThread = (s: ChatStoreState): ThreadItem | undefined => {
return threads.find((t) => t.id === s.portalThreadId);
};
+const currentActiveThread = (s: ChatStoreState): ThreadItem | undefined => {
+ if (!s.activeThreadId) return undefined;
+
+ const threads = currentTopicThreads(s);
+
+ return threads.find((t) => t.id === s.activeThreadId);
+};
+
+const isActiveThreadSubagent = (s: ChatStoreState): boolean => {
+ const thread = currentActiveThread(s);
+ return !!thread?.metadata?.subagentType;
+};
+
const getThreadsByTopic = (topicId?: string) => (s: ChatStoreState) => {
if (!topicId) return;
@@ -122,11 +135,13 @@ const portalDisplayChatsString = (s: ChatStoreState) => {
};
export const threadSelectors = {
+ currentActiveThread,
currentPortalThread,
currentTopicThreads,
getThreadsBySourceMsgId,
getThreadsByTopic,
hasThreadBySourceMsgId,
+ isActiveThreadSubagent,
portalAIChats,
portalAIChatsWithHistoryConfig,
portalDisplayChatsString,