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: update AgentCouncil style

canisminor199045630015e209
diff --git a/src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/index.tsx b/src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/index.tsx
index b417bebc205..0efae344cc1 100644
--- a/src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/index.tsx
+++ b/src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/index.tsx
@@ -1,66 +1 @@
-'use client';
-
-import { ActionIcon, Flexbox } from '@lobehub/ui';
-import { ChevronDown, ChevronUp } from 'lucide-react';
-import { memo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { MinimapIndicator } from './MinimapIndicator';
-import { useMinimapStyles } from './styles';
-import { useMinimapData } from './useMinimapData';
-import { MIN_MESSAGES_THRESHOLD } from './utils';
-
-const ChatMinimap = memo(() => {
- const { t } = useTranslation('chat');
- const { styles, cx } = useMinimapStyles();
- const [isHovered, setIsHovered] = useState(false);
-
- const { indicators, activeIndicatorPosition, handleJump, handleStep } = useMinimapData();
-
- if (indicators.length <= MIN_MESSAGES_THRESHOLD) return null;
-
- return (
- <Flexbox align={'center'} className={styles.container} justify={'center'}>
- <Flexbox
- className={styles.rail}
- onMouseEnter={() => setIsHovered(true)}
- onMouseLeave={() => setIsHovered(false)}
- role={'group'}
- >
- <ActionIcon
- aria-label={t('minimap.previousMessage')}
- className={cx(styles.arrow, isHovered && styles.arrowVisible)}
- icon={ChevronUp}
- onClick={() => handleStep('prev')}
- size={14}
- />
- <Flexbox className={styles.railContent}>
- {indicators.map(({ id, width, preview, role, virtuosoIndex }, position) => (
- <MinimapIndicator
- activePosition={activeIndicatorPosition}
- id={id}
- key={id}
- onJump={handleJump}
- position={position}
- preview={preview}
- role={role}
- virtuosoIndex={virtuosoIndex}
- width={width}
- />
- ))}
- </Flexbox>
- <ActionIcon
- aria-label={t('minimap.nextMessage')}
- className={cx(styles.arrow, isHovered && styles.arrowVisible)}
- icon={ChevronDown}
- onClick={() => handleStep('next')}
- size={14}
- />
- </Flexbox>
- </Flexbox>
- );
-});
-
-ChatMinimap.displayName = 'ChatMinimap';
-
-export default ChatMinimap;
+export { default } from '@/features/ChatMiniMap';
diff --git a/src/app/[variants]/(main)/group/features/Conversation/ChatMinimap/index.tsx b/src/app/[variants]/(main)/group/features/Conversation/ChatMinimap/index.tsx
index 2f915e4d3fc..0efae344cc1 100644
--- a/src/app/[variants]/(main)/group/features/Conversation/ChatMinimap/index.tsx
+++ b/src/app/[variants]/(main)/group/features/Conversation/ChatMinimap/index.tsx
@@ -1,359 +1 @@
-'use client';
-
-import { Flexbox, Icon } from '@lobehub/ui';
-import { Popover, Tooltip } from 'antd';
-import { createStyles, useTheme } from 'antd-style';
-import debug from 'debug';
-import isEqual from 'fast-deep-equal';
-import { ChevronDown, ChevronUp } from 'lucide-react';
-import { markdownToTxt } from 'markdown-to-txt';
-import { memo, useCallback, useMemo, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { conversationSelectors, useConversationStore } from '@/features/Conversation';
-
-const log = debug('lobe-react:chat-minimap');
-
-const MIN_WIDTH = 16;
-const MAX_WIDTH = 30;
-const MAX_CONTENT_LENGTH = 320;
-const MIN_MESSAGES = 3;
-
-const useStyles = createStyles(({ css, token }) => ({
- arrow: css`
- cursor: pointer;
-
- transform: translateX(4px);
-
- display: flex;
- align-items: center;
- justify-content: center;
-
- width: 24px;
- height: 24px;
- padding: 0;
- border: none;
- border-radius: 6px;
-
- color: ${token.colorTextTertiary};
-
- opacity: 0;
- background: none;
-
- transition: opacity 0.2s ease;
-
- &:hover {
- color: ${token.colorText};
- background: ${token.colorFill};
- }
-
- &:focus-visible {
- outline: none;
- box-shadow: 0 0 0 2px ${token.colorPrimaryBorder};
- }
- `,
- arrowVisible: css`
- opacity: 1;
- `,
- container: css`
- pointer-events: none;
-
- position: absolute;
- z-index: 1;
- inset-block: 16px 120px;
- inset-inline-end: 8px;
-
- width: 32px;
- `,
- indicator: css`
- cursor: pointer;
-
- flex-shrink: 0;
-
- min-width: ${MIN_WIDTH}px;
- height: 12px;
- padding-block: 4px;
- padding-inline: 4px;
- border: none;
- border-radius: 3px;
-
- background: none;
-
- transition:
- transform 0.2s ease,
- background-color 0.2s ease,
- box-shadow 0.2s ease;
-
- &:hover {
- transform: scaleX(1.05);
- background: ${token.colorFill};
- }
-
- &:focus-visible {
- outline: none;
- box-shadow: 0 0 0 2px ${token.colorPrimaryBorder};
- }
- `,
- indicatorActive: css`
- transform: scaleX(1.1);
- background: ${token.colorPrimary};
- box-shadow: 0 0 0 1px ${token.colorPrimaryHover};
- `,
- indicatorContent: css`
- width: 100%;
- height: 100%;
- border-radius: 3px;
- background: ${token.colorFillSecondary};
- `,
- indicatorContentActive: css`
- background: ${token.colorPrimary};
- `,
- popoverContent: css`
- max-width: 300px;
- `,
- popoverLabel: css`
- margin-block-end: 4px;
- font-size: 12px;
- font-weight: 600;
- color: ${token.colorTextSecondary};
- `,
- popoverText: css`
- color: ${token.colorText};
- word-break: break-word;
- `,
- rail: css`
- pointer-events: auto;
-
- display: flex;
- flex-direction: column;
- gap: 0;
- align-items: end;
- justify-content: space-between;
-
- width: 100%;
- height: fit-content;
- margin-block: 0;
- margin-inline: auto;
-
- &:hover .arrow {
- opacity: 1;
- }
- `,
- railContent: css`
- scrollbar-width: none;
-
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- gap: 0;
- align-items: end;
- justify-content: space-between;
-
- max-height: round(down, 50vh, 12px);
-
- /* Hide scrollbar for IE, Edge and Firefox */
- -ms-overflow-style: none;
-
- /* Hide scrollbar for Chrome, Safari and Opera */
- &::-webkit-scrollbar {
- display: none;
- }
- `,
-}));
-
-const getIndicatorWidth = (content: string | undefined) => {
- if (!content) return MIN_WIDTH;
-
- const ratio = Math.min(content.length / MAX_CONTENT_LENGTH, 1);
-
- return MIN_WIDTH + (MAX_WIDTH - MIN_WIDTH) * ratio;
-};
-
-const getPreviewText = (content: string | undefined) => {
- if (!content) return '';
-
- const plainText = markdownToTxt(content);
- const normalized = plainText.replaceAll(/\s+/g, ' ').trim();
- if (!normalized) return '';
-
- return normalized.slice(0, 100) + (normalized.length > 100 ? '…' : '');
-};
-
-interface MinimapIndicator {
- id: string;
- preview: string;
- role: 'user' | 'assistant';
- virtuosoIndex: number;
- width: number;
-}
-
-const ChatMinimap = memo(() => {
- const { t } = useTranslation('chat');
- const { styles, cx } = useStyles();
- const [isHovered, setIsHovered] = useState(false);
-
- const scrollMethods = useConversationStore(conversationSelectors.virtuaScrollMethods);
- const activeIndex = useConversationStore(conversationSelectors.activeIndex);
- const messages = useConversationStore(conversationSelectors.displayMessages, isEqual);
-
- const theme = useTheme();
-
- const indicators = useMemo<MinimapIndicator[]>(() => {
- return messages.reduce<MinimapIndicator[]>((acc, message, virtuosoIndex) => {
- if (message.role !== 'user' && message.role !== 'assistant') return acc;
-
- acc.push({
- id: message.id,
- preview: getPreviewText(message.content),
- role: message.role,
- virtuosoIndex,
- width: getIndicatorWidth(message.content),
- });
-
- return acc;
- }, []);
- }, [messages]);
-
- const indicatorIndexMap = useMemo(() => {
- const map = new Map<number, number>();
- indicators.forEach(({ virtuosoIndex }, position) => {
- map.set(virtuosoIndex, position);
- });
- return map;
- }, [indicators]);
-
- const activeIndicatorPosition = useMemo(() => {
- if (activeIndex === null) return null;
-
- log('> activeIndex', activeIndex);
- log('> indicatorIndexMap', indicatorIndexMap);
-
- return indicatorIndexMap.get(activeIndex) ?? null;
- }, [activeIndex, indicatorIndexMap]);
-
- const handleJump = useCallback(
- (virtIndex: number) => {
- scrollMethods?.scrollToIndex(virtIndex, { align: 'start', smooth: true });
- },
- [scrollMethods],
- );
-
- const handleStep = useCallback(
- (direction: 'prev' | 'next') => {
- if (!scrollMethods || indicators.length === 0) return;
-
- let targetPosition: number;
-
- if (activeIndicatorPosition !== null) {
- log('activeIndicatorPosition', activeIndicatorPosition);
- // We're on an indicator, move to prev/next
- const delta = direction === 'prev' ? -1 : 1;
- targetPosition = Math.min(
- Math.max(activeIndicatorPosition + delta, 0),
- Math.max(indicators.length - 1, 0),
- );
- } else if (activeIndex !== null) {
- // We're not on an indicator, find the nearest one in the direction
- if (direction === 'prev') {
- let matched = -1;
- for (let pos = indicators.length - 1; pos >= 0; pos -= 1) {
- if (indicators[pos].virtuosoIndex < activeIndex) {
- matched = pos;
- break;
- }
- }
- targetPosition = matched === -1 ? 0 : matched;
- } else {
- let matched = indicators.length - 1;
- for (const [pos, indicator] of indicators.entries()) {
- if (indicator.virtuosoIndex > activeIndex) {
- matched = pos;
- break;
- }
- }
- targetPosition = matched;
- }
- } else {
- // No active index, go to first/last
- targetPosition = direction === 'prev' ? indicators.length - 1 : 0;
- }
-
- const targetIndicator = indicators[targetPosition];
-
- if (!targetIndicator) return;
-
- scrollMethods.scrollToIndex(targetIndicator.virtuosoIndex, { align: 'start', smooth: true });
- },
- [activeIndex, activeIndicatorPosition, indicators, scrollMethods],
- );
-
- if (indicators.length <= MIN_MESSAGES) return null;
-
- return (
- <Flexbox align={'center'} className={styles.container} justify={'center'}>
- <Flexbox
- className={styles.rail}
- onMouseEnter={() => setIsHovered(true)}
- onMouseLeave={() => setIsHovered(false)}
- role={'group'}
- >
- <Tooltip mouseEnterDelay={0.1} placement={'left'} title={t('minimap.previousMessage')}>
- <button
- aria-label={t('minimap.previousMessage')}
- className={cx(styles.arrow, isHovered && styles.arrowVisible)}
- onClick={() => handleStep('prev')}
- type={'button'}
- >
- <Icon color={theme.colorTextTertiary} icon={ChevronUp} size={16} />
- </button>
- </Tooltip>
- <Flexbox className={styles.railContent}>
- {indicators.map(({ id, width, preview, role, virtuosoIndex }, position) => {
- const isActive = activeIndicatorPosition === position;
- const senderLabel =
- role === 'user' ? t('minimap.senderUser') : t('minimap.senderAssistant');
-
- const popoverContent = preview ? (
- <div className={styles.popoverContent}>
- <div className={styles.popoverLabel}>{senderLabel}</div>
- <div className={styles.popoverText}>{preview}</div>
- </div>
- ) : undefined;
-
- return (
- <Popover content={popoverContent} key={id} mouseEnterDelay={0.1} placement={'left'}>
- <button
- aria-current={isActive ? 'true' : undefined}
- aria-label={t('minimap.jumpToMessage', { index: position + 1 })}
- className={styles.indicator}
- onClick={() => handleJump(virtuosoIndex)}
- style={{ width }}
- type={'button'}
- >
- <div
- className={cx(
- styles.indicatorContent,
- isActive && styles.indicatorContentActive,
- )}
- />
- </button>
- </Popover>
- );
- })}
- </Flexbox>
- <Tooltip mouseEnterDelay={0.1} placement={'left'} title={t('minimap.nextMessage')}>
- <button
- aria-label={t('minimap.nextMessage')}
- className={cx(styles.arrow, isHovered && styles.arrowVisible)}
- onClick={() => handleStep('next')}
- type={'button'}
- >
- <Icon icon={ChevronDown} size={16} />
- </button>
- </Tooltip>
- </Flexbox>
- </Flexbox>
- );
-});
-
-export default ChatMinimap;
+export { default } from '@/features/ChatMiniMap';
diff --git a/src/app/[variants]/(main)/settings/stats/features/AiHeatmaps.tsx b/src/app/[variants]/(main)/settings/stats/features/AiHeatmaps.tsx
index 0b1f42a0c56..cb1aa7a6200 100644
--- a/src/app/[variants]/(main)/settings/stats/features/AiHeatmaps.tsx
+++ b/src/app/[variants]/(main)/settings/stats/features/AiHeatmaps.tsx
@@ -10,119 +10,119 @@ import { FORM_STYLE } from '@/const/layoutTokens';
import { useClientDataSWR } from '@/libs/swr';
import { messageService } from '@/services/message';
-const AiHeatmaps = memo<Omit<HeatmapsProps, 'data'> & { inShare?: boolean; mobile?: boolean }>(
- ({ inShare, mobile, ...rest }) => {
- const { t } = useTranslation('auth');
- const theme = useTheme();
- const { data, isLoading } = useClientDataSWR('stats-heatmaps', async () =>
- messageService.getHeatmaps(),
- );
+const AiHeatmaps = memo<
+ Omit<HeatmapsProps, 'data' | 'ref'> & { inShare?: boolean; mobile?: boolean }
+>(({ inShare, mobile, ...rest }) => {
+ const { t } = useTranslation('auth');
+ const theme = useTheme();
+ const { data, isLoading } = useClientDataSWR('stats-heatmaps', async () =>
+ messageService.getHeatmaps(),
+ );
- const days = data?.filter((item) => item.level > 0).length || '--';
- const hotDays = data?.filter((item) => item.level >= 3).length || '--';
+ const days = data?.filter((item) => item.level > 0).length || '--';
+ const hotDays = data?.filter((item) => item.level >= 3).length || '--';
- const content = (
- <Heatmaps
- blockMargin={mobile ? 3 : undefined}
- blockRadius={mobile ? 2 : undefined}
- blockSize={mobile ? 6 : 14}
- data={data || []}
- labels={{
- legend: {
- less: t('heatmaps.legend.less'),
- more: t('heatmaps.legend.more'),
- },
- months: [
- t('heatmaps.months.jan'),
- t('heatmaps.months.feb'),
- t('heatmaps.months.mar'),
- t('heatmaps.months.apr'),
- t('heatmaps.months.may'),
- t('heatmaps.months.jun'),
- t('heatmaps.months.jul'),
- t('heatmaps.months.aug'),
- t('heatmaps.months.sep'),
- t('heatmaps.months.oct'),
- t('heatmaps.months.nov'),
- t('heatmaps.months.dec'),
- ],
- tooltip: t('heatmaps.tooltip'),
- totalCount: t('heatmaps.totalCount'),
- }}
- loading={isLoading || !data}
- maxLevel={4}
- {...rest}
- />
- );
+ const content = (
+ <Heatmaps
+ blockMargin={mobile ? 3 : undefined}
+ blockRadius={mobile ? 2 : undefined}
+ blockSize={mobile ? 6 : 14}
+ data={data || []}
+ labels={{
+ legend: {
+ less: t('heatmaps.legend.less'),
+ more: t('heatmaps.legend.more'),
+ },
+ months: [
+ t('heatmaps.months.jan'),
+ t('heatmaps.months.feb'),
+ t('heatmaps.months.mar'),
+ t('heatmaps.months.apr'),
+ t('heatmaps.months.may'),
+ t('heatmaps.months.jun'),
+ t('heatmaps.months.jul'),
+ t('heatmaps.months.aug'),
+ t('heatmaps.months.sep'),
+ t('heatmaps.months.oct'),
+ t('heatmaps.months.nov'),
+ t('heatmaps.months.dec'),
+ ],
+ tooltip: t('heatmaps.tooltip'),
+ totalCount: t('heatmaps.totalCount'),
+ }}
+ loading={isLoading || !data}
+ maxLevel={4}
+ {...rest}
+ />
+ );
- const fillColor = readableColor(theme.gold);
- const tags = (
- <Flexbox
- gap={4}
- horizontal
+ const fillColor = readableColor(theme.gold);
+ const tags = (
+ <Flexbox
+ gap={4}
+ horizontal
+ style={{
+ alignSelf: 'center',
+ flex: 'none',
+ zoom: 0.9,
+ }}
+ >
+ <Tag
style={{
- alignSelf: 'center',
- flex: 'none',
- zoom: 0.9,
+ background: theme.colorText,
+ color: theme.colorBgLayout,
+ fontWeight: 500,
+ margin: 0,
}}
+ variant={'filled'}
>
- <Tag
- style={{
- background: theme.colorText,
- color: theme.colorBgLayout,
- fontWeight: 500,
- margin: 0,
- }}
- variant={'filled'}
- >
- {[days, t('stats.days')].join(' ')}
- </Tag>
- <Tag
- color={'gold'}
- icon={<Icon color={fillColor} fill={fillColor} icon={FlameIcon} />}
- style={{
- background: theme.gold,
- color: fillColor,
- fontWeight: 500,
- margin: 0,
- }}
- variant={'filled'}
- >
- {[hotDays, t('stats.days')].join(' ')}
- </Tag>
- </Flexbox>
- );
-
- if (inShare) {
- return (
- <Flexbox gap={4}>
- <Flexbox align={'baseline'} gap={4} horizontal justify={'space-between'}>
- <div
- style={{
- color: theme.colorTextDescription,
- fontSize: 12,
- }}
- >
- {t('stats.lastYearActivity')}
- </div>
- {tags}
- </Flexbox>
- {content}
- </Flexbox>
- );
- }
+ {[days, t('stats.days')].join(' ')}
+ </Tag>
+ <Tag
+ color={'gold'}
+ icon={<Icon color={fillColor} fill={fillColor} icon={FlameIcon} />}
+ style={{
+ background: theme.gold,
+ color: fillColor,
+ fontWeight: 500,
+ margin: 0,
+ }}
+ variant={'filled'}
+ >
+ {[hotDays, t('stats.days')].join(' ')}
+ </Tag>
+ </Flexbox>
+ );
+ if (inShare) {
return (
- <FormGroup
- extra={tags}
- style={FORM_STYLE.style}
- title={t('stats.lastYearActivity')}
- variant={'borderless'}
- >
- <Flexbox paddingBlock={24}>{content}</Flexbox>
- </FormGroup>
+ <Flexbox gap={4}>
+ <Flexbox align={'baseline'} gap={4} horizontal justify={'space-between'}>
+ <div
+ style={{
+ color: theme.colorTextDescription,
+ fontSize: 12,
+ }}
+ >
+ {t('stats.lastYearActivity')}
+ </div>
+ {tags}
+ </Flexbox>
+ {content}
+ </Flexbox>
);
- },
-);
+ }
+
+ return (
+ <FormGroup
+ extra={tags}
+ style={FORM_STYLE.style}
+ title={t('stats.lastYearActivity')}
+ variant={'borderless'}
+ >
+ <Flexbox paddingBlock={24}>{content}</Flexbox>
+ </FormGroup>
+ );
+});
export default AiHeatmaps;
diff --git a/src/components/Thinking/index.tsx b/src/components/Thinking/index.tsx
deleted file mode 100644
index 34b5e0eeaff..00000000000
--- a/src/components/Thinking/index.tsx
+++ /dev/null
@@ -1,214 +0,0 @@
-import { ChatCitationItem } from '@lobechat/types';
-import { CopyButton, Flexbox, Icon, Markdown, ScrollShadow } from '@lobehub/ui';
-import { createStyles } from 'antd-style';
-import { AtomIcon } from 'lucide-react';
-import { AnimatePresence, m as motion } from 'motion/react';
-import { rgba } from 'polished';
-import { CSSProperties, ReactNode, RefObject, memo, useEffect, useRef, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-const useStyles = createStyles(({ css, token }) => ({
- container: css`
- overflow: hidden;
- border-radius: ${token.borderRadius}px;
- color: ${token.colorTextTertiary};
- transition: all 0.2s ${token.motionEaseOut};
- `,
- contentScroll: css`
- max-height: min(40vh, 320px);
- padding-block-end: 8px;
- padding-inline: 8px;
- `,
- expand: css`
- color: ${token.colorTextTertiary};
- `,
- header: css`
- min-height: 32px;
- padding-block: 4px;
- padding-inline: 8px 4px;
-
- transition: background 0.2s ${token.motionEaseOut};
- transition: all 0.2s ${token.motionEaseOut};
-
- &:hover {
- background: ${token.colorFillQuaternary};
- }
- `,
-
- headerExpand: css`
- color: ${token.colorTextSecondary};
- `,
- shinyText: css`
- color: ${rgba(token.colorText, 0.45)};
-
- background: linear-gradient(
- 120deg,
- ${rgba(token.colorTextBase, 0)} 40%,
- ${token.colorTextSecondary} 50%,
- ${rgba(token.colorTextBase, 0)} 60%
- );
- background-clip: text;
- background-size: 200% 100%;
-
- animation: shine 1.5s linear infinite;
-
- @keyframes shine {
- 0% {
- background-position: 100%;
- }
-
- 100% {
- background-position: -100%;
- }
- }
- `,
- title: css`
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
-
- font-size: 12px;
- text-overflow: ellipsis;
- `,
-}));
-
-interface ThinkingProps {
- citations?: ChatCitationItem[];
- content?: string | ReactNode;
- duration?: number;
- style?: CSSProperties;
- thinking?: boolean;
- thinkingAnimated?: boolean;
-}
-
-const Thinking = memo<ThinkingProps>((props) => {
- const { content, duration, thinking, style, citations, thinkingAnimated } = props;
- const { t } = useTranslation(['components', 'common']);
- const { styles, cx, theme } = useStyles();
-
- const [showDetail, setShowDetail] = useState(false);
- const contentRef = useRef<HTMLDivElement | null>(null);
-
- useEffect(() => {
- setShowDetail(!!thinking);
- }, [thinking]);
-
- // 当内容变更且正在思考时,如果用户接近底部则自动滚动到底部
- useEffect(() => {
- if (!thinking || !showDetail) return;
- const container = contentRef.current;
- if (!container) return;
-
- // 仅当用户接近底部时才自动滚动,避免打断用户查看上方内容
- const distanceToBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
- const isNearBottom = distanceToBottom < 120;
-
- if (isNearBottom) {
- requestAnimationFrame(() => {
- container.scrollTop = container.scrollHeight;
- });
- }
- }, [content, thinking, showDetail]);
-
- // 展开时滚动到底部,便于查看最新内容
- useEffect(() => {
- if (!showDetail) return;
- const container = contentRef.current;
- if (!container) return;
- requestAnimationFrame(() => {
- container.scrollTop = container.scrollHeight;
- });
- }, [showDetail]);
-
- return (
- <Flexbox
- className={cx(styles.container, showDetail && styles.expand)}
- style={style}
- width={'100%'}
- >
- <Flexbox
- className={cx(styles.header, showDetail && styles.headerExpand)}
- distribution={'space-between'}
- flex={1}
- gap={8}
- horizontal
- onClick={() => {
- setShowDetail(!showDetail);
- }}
- style={{ cursor: 'pointer' }}
- width={'100%'}
- >
- {thinking ? (
- <Flexbox align={'center'} gap={8} horizontal width={'100%'}>
- <Icon color={theme.purple} icon={AtomIcon} />
- <Flexbox className={styles.shinyText} horizontal>
- {t('Thinking.thinking')}
- </Flexbox>
- </Flexbox>
- ) : (
- <Flexbox align={'center'} gap={8} horizontal width={'100%'}>
- <Icon color={showDetail ? theme.purple : undefined} icon={AtomIcon} />
- <Flexbox>
- {!duration
- ? t('Thinking.thoughtWithDuration')
- : t('Thinking.thought', { duration: ((duration || 0) / 1000).toFixed(1) })}
- </Flexbox>
- </Flexbox>
- )}
- <Flexbox gap={4} horizontal>
- {showDetail && content && typeof content === 'string' && (
- <div
- onClick={(event) => {
- event.stopPropagation();
- }}
- >
- <CopyButton content={content} size={'small'} title={t('copy', { ns: 'common' })} />
- </div>
- )}
- </Flexbox>
- </Flexbox>
- <AnimatePresence initial={false}>
- {showDetail && (
- <motion.div
- animate="open"
- exit="collapsed"
- initial="collapsed"
- style={{ overflow: 'hidden' }}
- transition={{
- duration: 0.2,
- ease: [0.4, 0, 0.2, 1], // 使用 ease-out 缓动函数
- }}
- variants={{
- collapsed: { opacity: 0, width: 'auto' },
- open: { opacity: 1, width: 'auto' },
- }}
- >
- <ScrollShadow
- className={styles.contentScroll}
- ref={contentRef as unknown as RefObject<HTMLDivElement>}
- size={12}
- >
- {typeof content === 'string' ? (
- <Markdown
- animated={thinkingAnimated}
- citations={citations}
- style={{
- overflow: 'unset',
- }}
- variant={'chat'}
- >
- {content}
- </Markdown>
- ) : (
- content
- )}
- </ScrollShadow>
- </motion.div>
- )}
- </AnimatePresence>
- </Flexbox>
- );
-});
-
-export default Thinking;
diff --git a/src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/MinimapIndicator.tsx b/src/features/ChatMiniMap/MinimapIndicator.tsx
similarity index 100%
rename from src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/MinimapIndicator.tsx
rename to src/features/ChatMiniMap/MinimapIndicator.tsx
diff --git a/src/features/ChatMiniMap/index.tsx b/src/features/ChatMiniMap/index.tsx
new file mode 100644
index 00000000000..b417bebc205
--- /dev/null
+++ b/src/features/ChatMiniMap/index.tsx
@@ -0,0 +1,66 @@
+'use client';
+
+import { ActionIcon, Flexbox } from '@lobehub/ui';
+import { ChevronDown, ChevronUp } from 'lucide-react';
+import { memo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { MinimapIndicator } from './MinimapIndicator';
+import { useMinimapStyles } from './styles';
+import { useMinimapData } from './useMinimapData';
+import { MIN_MESSAGES_THRESHOLD } from './utils';
+
+const ChatMinimap = memo(() => {
+ const { t } = useTranslation('chat');
+ const { styles, cx } = useMinimapStyles();
+ const [isHovered, setIsHovered] = useState(false);
+
+ const { indicators, activeIndicatorPosition, handleJump, handleStep } = useMinimapData();
+
+ if (indicators.length <= MIN_MESSAGES_THRESHOLD) return null;
+
+ return (
+ <Flexbox align={'center'} className={styles.container} justify={'center'}>
+ <Flexbox
+ className={styles.rail}
+ onMouseEnter={() => setIsHovered(true)}
+ onMouseLeave={() => setIsHovered(false)}
+ role={'group'}
+ >
+ <ActionIcon
+ aria-label={t('minimap.previousMessage')}
+ className={cx(styles.arrow, isHovered && styles.arrowVisible)}
+ icon={ChevronUp}
+ onClick={() => handleStep('prev')}
+ size={14}
+ />
+ <Flexbox className={styles.railContent}>
+ {indicators.map(({ id, width, preview, role, virtuosoIndex }, position) => (
+ <MinimapIndicator
+ activePosition={activeIndicatorPosition}
+ id={id}
+ key={id}
+ onJump={handleJump}
+ position={position}
+ preview={preview}
+ role={role}
+ virtuosoIndex={virtuosoIndex}
+ width={width}
+ />
+ ))}
+ </Flexbox>
+ <ActionIcon
+ aria-label={t('minimap.nextMessage')}
+ className={cx(styles.arrow, isHovered && styles.arrowVisible)}
+ icon={ChevronDown}
+ onClick={() => handleStep('next')}
+ size={14}
+ />
+ </Flexbox>
+ </Flexbox>
+ );
+});
+
+ChatMinimap.displayName = 'ChatMinimap';
+
+export default ChatMinimap;
diff --git a/src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/styles.ts b/src/features/ChatMiniMap/styles.ts
similarity index 100%
rename from src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/styles.ts
rename to src/features/ChatMiniMap/styles.ts
diff --git a/src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/types.ts b/src/features/ChatMiniMap/types.ts
similarity index 100%
rename from src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/types.ts
rename to src/features/ChatMiniMap/types.ts
diff --git a/src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/useMinimapData.ts b/src/features/ChatMiniMap/useMinimapData.ts
similarity index 100%
rename from src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/useMinimapData.ts
rename to src/features/ChatMiniMap/useMinimapData.ts
diff --git a/src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/utils.ts b/src/features/ChatMiniMap/utils.ts
similarity index 100%
rename from src/app/[variants]/(main)/chat/features/Conversation/ChatMinimap/utils.ts
rename to src/features/ChatMiniMap/utils.ts
diff --git a/src/features/Conversation/Markdown/plugins/LobeThinking/Render.tsx b/src/features/Conversation/Markdown/plugins/LobeThinking/Render.tsx
index 5cd7224cfa8..d173e13f1b9 100644
--- a/src/features/Conversation/Markdown/plugins/LobeThinking/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/LobeThinking/Render.tsx
@@ -1,7 +1,7 @@
import { memo } from 'react';
-import Thinking from '@/components/Thinking';
import { ARTIFACT_THINKING_TAG } from '@/const/index';
+import Thinking from '@/features/Conversation/components/Thinking';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
diff --git a/src/features/Conversation/Markdown/plugins/Thinking/Render.tsx b/src/features/Conversation/Markdown/plugins/Thinking/Render.tsx
index 51f9118d3ed..23ae3a0b791 100644
--- a/src/features/Conversation/Markdown/plugins/Thinking/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/Thinking/Render.tsx
@@ -1,6 +1,6 @@
import { memo } from 'react';
-import Thinking from '@/components/Thinking';
+import Thinking from '@/features/Conversation/components/Thinking';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
diff --git a/src/features/Conversation/Messages/AgentCouncil/CouncilMember.tsx b/src/features/Conversation/Messages/AgentCouncil/CouncilMember.tsx
index 884ef3beae3..e64efbf4970 100644
--- a/src/features/Conversation/Messages/AgentCouncil/CouncilMember.tsx
+++ b/src/features/Conversation/Messages/AgentCouncil/CouncilMember.tsx
@@ -1,108 +1,86 @@
'use client';
-import { Flexbox } from '@lobehub/ui';
-import { createStyles } from 'antd-style';
+import { ScrollShadow } from '@lobehub/ui';
import isEqual from 'fast-deep-equal';
import { memo } from 'react';
-import Avatar from '@/features/Conversation/ChatItem/components/Avatar';
-import Title from '@/features/Conversation/ChatItem/components/Title';
+import { LOADING_FLAT } from '@/const/message';
+import { ChatItem } from '@/features/Conversation/ChatItem';
+import ErrorMessageExtra, { useErrorContent } from '@/features/Conversation/Error';
+import { actionBarHolder } from '@/features/Conversation/Messages/Assistant';
+import { AssistantMessageExtra } from '@/features/Conversation/Messages/Assistant/Extra';
+import { normalizeThinkTags, processWithArtifact } from '@/features/Conversation/utils/markdown';
import type { UIChatMessage } from '@/types/index';
import { useAgentMeta } from '../../hooks';
import { messageStateSelectors, useConversationStore } from '../../store';
import MessageContent from '../Assistant/components/MessageContent';
-import Usage from '../components/Extras/Usage';
-import type { DisplayMode } from './index';
-
-const useStyles = createStyles(({ css, token, responsive }) => ({
- cardHorizontal: css`
- scroll-snap-align: start;
-
- overflow: hidden;
- flex: 0 0 auto;
-
- width: 480px;
- padding: 12px;
- border: 1px solid ${token.colorBorderSecondary};
- border-radius: ${token.borderRadiusLG}px;
-
- background: ${token.colorBgContainer};
-
- ${responsive.mobile} {
- width: 85vw;
- max-width: 360px;
- }
- `,
- // Tab mode: full width, no border
- cardTab: css`
- overflow: hidden;
-
- width: 100%;
- padding: 12px;
- border: 1px solid ${token.colorBorderSecondary};
- border-radius: ${token.borderRadiusLG}px;
-
- background: ${token.colorBgContainer};
- `,
- // Vertical mode: full width with border
- cardVertical: css`
- overflow: hidden;
-
- width: 100%;
- padding: 12px;
- border: 1px solid ${token.colorBorderSecondary};
- border-radius: ${token.borderRadiusLG}px;
-
- background: ${token.colorBgContainer};
- `,
- content: css`
- overflow: auto;
- flex: 1;
- `,
-}));
interface CouncilMemberProps {
index: number;
- message: UIChatMessage;
- mode?: DisplayMode;
+ item: UIChatMessage;
+ scrollShadow?: boolean;
}
-/**
- * CouncilMember - Renders a single agent's response in the council grid
- *
- * Handles both:
- * - assistantGroup: Agent response with tool calls
- * - assistant: Simple agent response without tools
- */
-const CouncilMember = memo<CouncilMemberProps>(({ message, mode = 'horizontal' }) => {
- const { styles, cx } = useStyles();
-
- const { agentId, performance, model, provider, usage, createdAt, id } = message;
+const CouncilMember = memo<CouncilMemberProps>(({ scrollShadow, item }) => {
+ const {
+ id,
+ agentId,
+ error,
+ content,
+ createdAt,
+ tools,
+ extra,
+ model,
+ provider,
+ performance,
+ usage,
+ metadata,
+ } = item;
const avatar = useAgentMeta(agentId);
- const creating = useConversationStore(messageStateSelectors.isMessageCreating(id));
-
- const cardClassName = cx({
- [styles.cardHorizontal]: mode === 'horizontal',
- [styles.cardTab]: mode === 'tab',
- [styles.cardVertical]: mode === 'vertical',
- });
-
+ const editing = useConversationStore(messageStateSelectors.isMessageEditing(id));
+ const generating = useConversationStore(messageStateSelectors.isMessageGenerating(id));
+ const errorContent = useErrorContent(error);
+ const message = !editing ? normalizeThinkTags(processWithArtifact(content)) : content;
+ const contentNode = <MessageContent {...item} />;
return (
- <Flexbox className={cardClassName} gap={12}>
- <Flexbox align={'center'} gap={4} horizontal>
- <Avatar avatar={avatar} loading={creating} />
- <Title avatar={avatar} showTitle time={createdAt} />
- </Flexbox>
-
- <Flexbox className={styles.content} gap={8}>
- <MessageContent {...message} />
- {model && (
- <Usage model={model} performance={performance} provider={provider!} usage={usage} />
- )}
- </Flexbox>
- </Flexbox>
+ <ChatItem
+ aboveMessage={null}
+ actions={actionBarHolder}
+ avatar={avatar}
+ customErrorRender={(error) => <ErrorMessageExtra data={item} error={error} />}
+ editing={editing}
+ error={
+ errorContent && error && (message === LOADING_FLAT || !message) ? errorContent : undefined
+ }
+ id={id}
+ loading={generating}
+ message={message}
+ messageExtra={
+ <AssistantMessageExtra
+ content={content}
+ extra={extra}
+ id={id}
+ model={model!}
+ performance={performance! || metadata}
+ provider={provider!}
+ tools={tools}
+ usage={usage! || metadata}
+ />
+ }
+ placement={'left'}
+ showTitle
+ time={createdAt}
+ >
+ {scrollShadow ? (
+ <ScrollShadow height={'max(33vh, 480px)'} hideScrollBar size={8}>
+ {contentNode}
+ </ScrollShadow>
+ ) : (
+ contentNode
+ )}
+ </ChatItem>
);
}, isEqual);
diff --git a/src/features/Conversation/Messages/AgentCouncil/index.tsx b/src/features/Conversation/Messages/AgentCouncil/index.tsx
index 9b536333a7d..c36c1a88a7c 100644
--- a/src/features/Conversation/Messages/AgentCouncil/index.tsx
+++ b/src/features/Conversation/Messages/AgentCouncil/index.tsx
@@ -1,81 +1,21 @@
'use client';
import { UIChatMessage } from '@lobechat/types';
-import { Flexbox } from '@lobehub/ui';
-import { Segmented } from 'antd';
-import { createStyles } from 'antd-style';
+import { Flexbox, Icon, ScrollShadow } from '@lobehub/ui';
+import { Divider, Segmented } from 'antd';
import isEqual from 'fast-deep-equal';
-import { Columns2, Layers, StretchHorizontal } from 'lucide-react';
-import { memo, useState } from 'react';
+import { BotIcon, Columns2, Layers } from 'lucide-react';
+import { Fragment, memo, useState } from 'react';
+import { CONVERSATION_MIN_WIDTH } from '@/const/layoutTokens';
import WideScreenContainer from '@/features/WideScreenContainer';
+import { useGlobalStore } from '@/store/global';
+import { systemStatusSelectors } from '@/store/global/selectors';
import { dataSelectors, useConversationStore } from '../../store';
import CouncilMember from './CouncilMember';
-export type DisplayMode = 'horizontal' | 'tab' | 'vertical';
-
-const useStyles = createStyles(({ css, token, responsive }) => ({
- container: css`
- overflow: visible;
- width: calc(100% + 32px);
- margin-inline: -16px;
- padding-inline: 16px;
- `,
- header: css`
- display: flex;
- justify-content: flex-end;
- margin-block-end: 8px;
- `,
- horizontalScroll: css`
- scroll-behavior: smooth;
- scrollbar-color: ${token.colorBorderSecondary} transparent;
- scrollbar-width: thin;
- scroll-snap-type: x mandatory;
-
- overflow: auto hidden;
- display: flex;
- gap: ${token.paddingMD}px;
-
- padding-block: 4px;
-
- &::-webkit-scrollbar {
- height: 6px;
- }
-
- &::-webkit-scrollbar-track {
- background: transparent;
- }
-
- &::-webkit-scrollbar-thumb {
- border-radius: 3px;
- background: ${token.colorBorderSecondary};
-
- &:hover {
- background: ${token.colorBorder};
- }
- }
-
- ${responsive.mobile} {
- scrollbar-width: none;
-
- &::-webkit-scrollbar {
- display: none;
- }
- }
- `,
- tabContent: css`
- width: 100%;
- `,
- tabSelector: css`
- margin-block-end: 12px;
- `,
- verticalStack: css`
- display: flex;
- flex-direction: column;
- gap: ${token.paddingMD}px;
- `,
-}));
+export type DisplayMode = 'horizontal' | 'tab';
interface AgentCouncilMessageProps {
id: string;
@@ -83,22 +23,12 @@ interface AgentCouncilMessageProps {
isLatestItem?: boolean;
}
-/**
- * AgentCouncilMessage - Renders multiple agent responses with switchable layouts
- *
- * Display modes:
- * - horizontal: Side by side with horizontal scroll (default)
- * - tab: Tabbed view with one agent per tab
- * - vertical: Stacked vertically for comparison
- */
const AgentCouncilMessage = memo<AgentCouncilMessageProps>(({ id }) => {
- const { styles } = useStyles();
const [displayMode, setDisplayMode] = useState<DisplayMode>('horizontal');
const [activeTab, setActiveTab] = useState(0);
-
+ const wideScreen = useGlobalStore(systemStatusSelectors.wideScreen);
const item = useConversationStore(dataSelectors.getDisplayMessageById(id), isEqual)!;
const members = (item as UIChatMessage)?.members as UIChatMessage[] | undefined;
-
if (!members || members.length === 0) {
return null;
}
@@ -111,72 +41,97 @@ const AgentCouncilMessage = memo<AgentCouncilMessageProps>(({ id }) => {
return (
<WideScreenContainer>
- <Flexbox className={styles.tabContent}>
- <div>
- <Segmented
- className={styles.tabSelector}
- onChange={(value) => setActiveTab(Number(value))}
- options={members.map((member, idx) => ({
- label: `Agent ${idx + 1}`,
- value: idx,
- }))}
- value={activeTab}
- />
- </div>
- <CouncilMember index={activeTab} message={activeMember} mode="tab" />
- </Flexbox>
+ <CouncilMember index={activeTab} item={activeMember} scrollShadow />
</WideScreenContainer>
);
}
- case 'vertical': {
+ default: {
+ if (members.length < 2) {
+ return (
+ <WideScreenContainer gap={16}>
+ {members.map((member, idx) => {
+ if (!member) return null;
+ return <CouncilMember index={idx} item={member} key={member.id} />;
+ })}
+ </WideScreenContainer>
+ );
+ }
+ const MIN_WIDTH = CONVERSATION_MIN_WIDTH / 2;
return (
- <WideScreenContainer>
- <div className={styles.verticalStack}>
+ <ScrollShadow hideScrollBar offset={16} orientation={'horizontal'} size={4}>
+ <Flexbox
+ horizontal
+ justify={wideScreen ? 'flex-start' : 'center'}
+ paddingInline={16}
+ style={{
+ minWidth: MIN_WIDTH * members.length + 32 + 16 * (members.length - 1),
+ }}
+ >
{members.map((member, idx) => {
if (!member) return null;
return (
- <CouncilMember index={idx} key={member.id} message={member} mode="vertical" />
+ <Fragment key={member.id}>
+ <Flexbox
+ gap={12}
+ key={member.id}
+ style={{
+ minWidth: MIN_WIDTH,
+ position: 'relative',
+ }}
+ width={`min(${MIN_WIDTH}px, 100%)`}
+ >
+ <CouncilMember index={idx} item={member} scrollShadow />
+ </Flexbox>
+ {idx < members.length - 1 && (
+ <Divider
+ dashed
+ orientation={'vertical'}
+ style={{ height: 'unset', marginInline: 16 }}
+ />
+ )}
+ </Fragment>
);
})}
- </div>
- </WideScreenContainer>
- );
- }
-
- default: {
- return (
- <div className={styles.horizontalScroll}>
- {members.map((member, idx) => {
- if (!member) return null;
- return (
- <CouncilMember index={idx} key={member.id} message={member} mode="horizontal" />
- );
- })}
- </div>
+ </Flexbox>
+ </ScrollShadow>
);
}
}
};
return (
- <Flexbox className={styles.container}>
+ <>
<WideScreenContainer>
- <div className={styles.header}>
+ <Flexbox align={'center'} height={48} horizontal justify={'space-between'} paddingBlock={8}>
+ {displayMode === 'tab' ? (
+ <Segmented
+ onChange={(value) => setActiveTab(Number(value))}
+ options={members.map((_, idx) => {
+ return {
+ icon: <Icon icon={BotIcon} size={14} />,
+ value: idx,
+ };
+ })}
+ size={'small'}
+ value={activeTab}
+ />
+ ) : (
+ <div />
+ )}
<Segmented
onChange={(value) => setDisplayMode(value as DisplayMode)}
options={[
- { icon: <StretchHorizontal size={14} />, value: 'horizontal' },
- { icon: <Layers size={14} />, value: 'tab' },
- { icon: <Columns2 size={14} />, value: 'vertical' },
+ { icon: <Icon icon={Columns2} />, value: 'horizontal' },
+ { icon: <Icon icon={Layers} />, value: 'tab' },
]}
size="small"
value={displayMode}
/>
- </div>
+ </Flexbox>
</WideScreenContainer>
{renderContent()}
- </Flexbox>
+ </>
);
}, isEqual);
diff --git a/src/features/Conversation/Messages/Assistant/index.tsx b/src/features/Conversation/Messages/Assistant/index.tsx
index ce9c04d7453..9d1e793f329 100644
--- a/src/features/Conversation/Messages/Assistant/index.tsx
+++ b/src/features/Conversation/Messages/Assistant/index.tsx
@@ -1,23 +1,12 @@
'use client';
import { LOADING_FLAT } from '@lobechat/const';
-import { Tag } from '@lobehub/ui';
import isEqual from 'fast-deep-equal';
-import { type MouseEventHandler, memo, useCallback, useMemo } from 'react';
-import { useTranslation } from 'react-i18next';
+import { type MouseEventHandler, memo, useCallback } from 'react';
import { MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES } from '@/const/messageActionPortal';
import { ChatItem } from '@/features/Conversation/ChatItem';
import { useNewScreen } from '@/features/Conversation/Messages/components/useNewScreen';
-import { useOpenChatSettings } from '@/hooks/useInterceptingRoutes';
-import { useAgentStore } from '@/store/agent';
-import { builtinAgentSelectors } from '@/store/agent/selectors';
-import { agentGroupSelectors, useAgentGroupStore } from '@/store/agentGroup';
-import { useGlobalStore } from '@/store/global';
-import { useSessionStore } from '@/store/session';
-import { sessionSelectors } from '@/store/session/selectors';
-import { useUserStore } from '@/store/user';
-import { userProfileSelectors } from '@/store/user/selectors';
import ErrorMessageExtra, { useErrorContent } from '../../Error';
import { useAgentMeta, useDoubleClickEdit } from '../../hooks';
@@ -31,9 +20,10 @@ import MessageBranch from '../components/MessageBranch';
import { AssistantMessageExtra } from './Extra';
import MessageContent from './components/MessageContent';
-const actionBarHolder = (
+export const actionBarHolder = (
<div {...{ [MESSAGE_ACTION_BAR_PORTAL_ATTRIBUTES.assistant]: '' }} style={{ height: '28px' }} />
);
+
interface AssistantMessageProps {
disableEditing?: boolean;
id: string;
@@ -57,14 +47,12 @@ const AssistantMessage = memo<AssistantMessageProps>(
extra,
model,
provider,
- targetId,
performance,
usage,
metadata,
} = item;
const avatar = useAgentMeta(agentId);
- const { t } = useTranslation('chat');
// Get editing and generating state from ConversationStore
const editing = useConversationStore(messageStateSelectors.isMessageEditing(id));
@@ -77,42 +65,6 @@ const AssistantMessage = memo<AssistantMessageProps>(
// remove line breaks in artifact tag to make the ast transform easier
const message = !editing ? normalizeThinkTags(processWithArtifact(content)) : content;
- const isGroupSession = useSessionStore(sessionSelectors.isCurrentSessionGroupSession);
- const groupConfig = useAgentGroupStore(agentGroupSelectors.currentGroupConfig);
-
- const reducted =
- isGroupSession && targetId !== null && targetId !== 'user' && !groupConfig?.revealDM;
-
- // Get target name for DM indicator
- const userName = useUserStore(userProfileSelectors.nickName) || 'User';
- const agents = useSessionStore(sessionSelectors.currentGroupAgents);
-
- const dmIndicator = useMemo(() => {
- if (!targetId) return undefined;
-
- let targetName = targetId;
- if (targetId === 'user') {
- targetName = t('dm.you');
- } else {
- const targetAgent = agents?.find((agent) => agent.id === targetId);
- targetName = targetAgent?.title || targetId;
- }
-
- return <Tag>{t('dm.visibleTo', { target: targetName })}</Tag>;
- }, [targetId, userName, agents, t]);
-
- const isInbox = useAgentStore(builtinAgentSelectors.isInboxAgent);
- const [toggleSystemRole] = useGlobalStore((s) => [s.toggleSystemRole]);
- const openChatSettings = useOpenChatSettings();
-
- const onAvatarClick = useCallback(() => {
- if (!isInbox) {
- toggleSystemRole(true);
- } else {
- openChatSettings();
- }
- }, [isInbox]);
-
const onDoubleClick = useDoubleClickEdit({ disableEditing, error, id, role });
const setMessageItemActionElementPortialContext =
useSetMessageItemActionElementPortialContext();
@@ -150,7 +102,7 @@ const AssistantMessage = memo<AssistantMessageProps>(
}
id={id}
loading={generating}
- message={reducted ? `*${t('hideForYou')}*` : message}
+ message={message}
messageExtra={
<AssistantMessageExtra
content={content}
@@ -164,13 +116,11 @@ const AssistantMessage = memo<AssistantMessageProps>(
/>
}
newScreen={newScreen}
- onAvatarClick={onAvatarClick}
onDoubleClick={onDoubleClick}
onMouseEnter={onMouseEnter}
placement={'left'}
showTitle
time={createdAt}
- titleAddon={dmIndicator}
>
<MessageContent {...item} />
</ChatItem>
diff --git a/src/features/Conversation/Messages/components/Reasoning.tsx b/src/features/Conversation/Messages/components/Reasoning.tsx
index 7cb4bd51379..46a0f9a4914 100644
--- a/src/features/Conversation/Messages/components/Reasoning.tsx
+++ b/src/features/Conversation/Messages/components/Reasoning.tsx
@@ -2,12 +2,12 @@ import { MessageContentPart } from '@lobechat/types';
import { deserializeParts } from '@lobechat/utils';
import { memo } from 'react';
-import Thinking from '@/components/Thinking';
-import { RichContentRenderer } from './RichContentRenderer';
+import Thinking from '@/features/Conversation/components/Thinking';
import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { messageStateSelectors, useConversationStore } from '../../store';
+import { RichContentRenderer } from './RichContentRenderer';
interface ReasoningProps {
content?: string;
diff --git a/src/features/Conversation/components/Thinking/StatusIndicator.tsx b/src/features/Conversation/components/Thinking/StatusIndicator.tsx
new file mode 100644
index 00000000000..31ed923eb81
--- /dev/null
+++ b/src/features/Conversation/components/Thinking/StatusIndicator.tsx
@@ -0,0 +1,40 @@
+import { Block, Icon } from '@lobehub/ui';
+import { useTheme } from 'antd-style';
+import { AtomIcon, Loader2Icon } from 'lucide-react';
+import { memo } from 'react';
+
+interface StatusIndicatorProps {
+ showDetail?: boolean;
+ thinking?: boolean;
+}
+
+const StatusIndicator = memo<StatusIndicatorProps>(({ thinking, showDetail }) => {
+ const theme = useTheme();
+ let icon;
+
+ if (thinking) {
+ icon = <Icon color={theme.colorTextDescription} icon={Loader2Icon} spin />;
+ } else {
+ icon = <Icon color={showDetail ? theme.purple : theme.colorTextDescription} icon={AtomIcon} />;
+ }
+
+ return (
+ <Block
+ align={'center'}
+ flex={'none'}
+ gap={4}
+ height={24}
+ horizontal
+ justify={'center'}
+ style={{
+ fontSize: 12,
+ }}
+ variant={'outlined'}
+ width={24}
+ >
+ {icon}
+ </Block>
+ );
+});
+
+export default StatusIndicator;
diff --git a/src/features/Conversation/components/Thinking/Title.tsx b/src/features/Conversation/components/Thinking/Title.tsx
new file mode 100644
index 00000000000..cf9edbad4d1
--- /dev/null
+++ b/src/features/Conversation/components/Thinking/Title.tsx
@@ -0,0 +1,40 @@
+import { Flexbox, Text } from '@lobehub/ui';
+import { createStyles } from 'antd-style';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { shinyTextStylish } from '@/styles/loading';
+
+import StatusIndicator from './StatusIndicator';
+
+const useStyles = createStyles(({ token }) => ({
+ shinyText: shinyTextStylish(token),
+}));
+
+interface ThinkingTitleProps {
+ duration?: number;
+ showDetail?: boolean;
+ thinking?: boolean;
+}
+
+const ThinkingTitle = memo<ThinkingTitleProps>(({ showDetail, thinking, duration }) => {
+ const { t } = useTranslation('components');
+ const { styles } = useStyles();
+
+ return (
+ <Flexbox align={'center'} gap={6} horizontal>
+ <StatusIndicator showDetail={showDetail} thinking={thinking} />
+ {thinking ? (
+ <span className={styles.shinyText}>{t('Thinking.thinking')}</span>
+ ) : (
+ <Text type={'secondary'}>
+ {!duration
+ ? t('Thinking.thoughtWithDuration')
+ : t('Thinking.thought', { duration: ((duration || 0) / 1000).toFixed(1) })}
+ </Text>
+ )}
+ </Flexbox>
+ );
+});
+
+export default ThinkingTitle;
diff --git a/src/features/Conversation/components/Thinking/index.tsx b/src/features/Conversation/components/Thinking/index.tsx
new file mode 100644
index 00000000000..3e34f7b99aa
--- /dev/null
+++ b/src/features/Conversation/components/Thinking/index.tsx
@@ -0,0 +1,106 @@
+import { Accordion, AccordionItem, ScrollShadow } from '@lobehub/ui';
+import { createStyles } from 'antd-style';
+import { CSSProperties, ReactNode, RefObject, memo, useEffect, useRef, useState } from 'react';
+
+import MarkdownMessage from '@/features/Conversation/Markdown';
+import { ChatCitationItem } from '@/types/index';
+
+import Title from './Title';
+
+const useStyles = createStyles(({ css, token }) => ({
+ contentScroll: css`
+ max-height: min(40vh, 320px);
+ padding-block-end: 8px;
+ padding-inline: 8px;
+ color: ${token.colorTextDescription};
+
+ article * {
+ color: ${token.colorTextDescription};
+ }
+ `,
+}));
+
+interface ThinkingProps {
+ citations?: ChatCitationItem[];
+ content?: string | ReactNode;
+ duration?: number;
+ style?: CSSProperties;
+ thinking?: boolean;
+ thinkingAnimated?: boolean;
+}
+
+const Thinking = memo<ThinkingProps>((props) => {
+ const { content, duration, thinking, citations, thinkingAnimated } = props;
+ const { styles } = useStyles();
+ const [showDetail, setShowDetail] = useState(false);
+ const contentRef = useRef<HTMLDivElement | null>(null);
+
+ useEffect(() => {
+ setShowDetail(!!thinking);
+ }, [thinking]);
+
+ // 当内容变更且正在思考时,如果用户接近底部则自动滚动到底部
+ useEffect(() => {
+ if (!thinking || !showDetail) return;
+ const container = contentRef.current;
+ if (!container) return;
+
+ // 仅当用户接近底部时才自动滚动,避免打断用户查看上方内容
+ const distanceToBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
+ const isNearBottom = distanceToBottom < 120;
+
+ if (isNearBottom) {
+ requestAnimationFrame(() => {
+ container.scrollTop = container.scrollHeight;
+ });
+ }
+ }, [content, thinking, showDetail]);
+
+ // 展开时滚动到底部,便于查看最新内容
+ useEffect(() => {
+ if (!showDetail) return;
+ const container = contentRef.current;
+ if (!container) return;
+ requestAnimationFrame(() => {
+ container.scrollTop = container.scrollHeight;
+ });
+ }, [showDetail]);
+
+ return (
+ <Accordion
+ expandedKeys={showDetail ? ['thinking'] : []}
+ gap={8}
+ onExpandedChange={(keys) => setShowDetail(keys.length > 0)}
+ >
+ <AccordionItem
+ itemKey={'thinking'}
+ paddingBlock={4}
+ paddingInline={4}
+ title={<Title duration={duration} showDetail={showDetail} thinking={thinking} />}
+ >
+ <ScrollShadow
+ className={styles.contentScroll}
+ ref={contentRef as unknown as RefObject<HTMLDivElement>}
+ size={12}
+ >
+ {typeof content === 'string' ? (
+ <MarkdownMessage
+ animated={thinkingAnimated}
+ citations={citations}
+ style={{
+ overflow: 'unset',
+ }}
+ variant={'chat'}
+ >
+ {content}
+ </MarkdownMessage>
+ ) : (
+ content
+ )}
+ </ScrollShadow>
+ </AccordionItem>
+ </Accordion>
+ );
+});
+
+export default Thinking;