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(messages): group pinned rows, center preview-less rows, fade sending messages, red rail badge (#22514)

Arvin Xucd7eb1aeb4ad
diff --git a/src/features/Channels/ChannelConversation.tsx b/src/features/Channels/ChannelConversation.tsx
index d02f4477e43..b33b4893575 100644
--- a/src/features/Channels/ChannelConversation.tsx
+++ b/src/features/Channels/ChannelConversation.tsx
@@ -221,6 +221,7 @@ const Timeline = ({
<ChannelMessage
continuation={continuation}
message={item.message}
+ pending={outgoingById.get(item.message.id)!.status === 'sending'}
threadId={threadId}
delivery={
<OutgoingStatus
diff --git a/src/features/Channels/ChannelMessage.tsx b/src/features/Channels/ChannelMessage.tsx
index dd784621559..0755c5e62d2 100644
--- a/src/features/Channels/ChannelMessage.tsx
+++ b/src/features/Channels/ChannelMessage.tsx
@@ -53,6 +53,7 @@ export const ChannelMessage = ({
onStartThread,
onReply,
onJumpToMessage,
+ pending = false,
}: {
continuation?: boolean;
/** For a message the server has not confirmed: its send status, in place of routing. */
@@ -65,6 +66,8 @@ export const ChannelMessage = ({
onStartThread?: (draft: ChannelThreadDraft) => void;
onReply?: (message: ChannelPublicMessage) => void;
onJumpToMessage?: (message: ChannelReplyTarget) => void;
+ /** Sent from this tab and not yet confirmed by the server. */
+ pending?: boolean;
threadId?: string | null;
}) => {
const { t, i18n } = useTranslation('channel');
@@ -104,6 +107,7 @@ export const ChannelMessage = ({
.filter(Boolean);
return (
<div
+ aria-busy={pending || undefined}
aria-label={message.author.name || t('deletedMember')}
data-continuation={compact || undefined}
data-message-id={message.id}
@@ -112,6 +116,7 @@ export const ChannelMessage = ({
styles.messageRow,
compact && (onReply || canBranch) && styles.continuationWithAction,
highlighted && styles.highlightedMessage,
+ pending && styles.pendingMessage,
stylex.defaultMarker(),
)}
>
diff --git a/src/features/Channels/OutgoingStatus.tsx b/src/features/Channels/OutgoingStatus.tsx
index ddcfe6b2957..22f72a21ac3 100644
--- a/src/features/Channels/OutgoingStatus.tsx
+++ b/src/features/Channels/OutgoingStatus.tsx
@@ -1,13 +1,13 @@
import { Button, Icon } from '@lobehub/ui';
import * as stylex from '@stylexjs/stylex';
-import { CircleAlert, Loader2 } from 'lucide-react';
+import { CircleAlert } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { channelActions, type ChannelOutgoingMessage } from '@/store/channel';
-import { statusStyles, styles, toneStyles } from './styles';
+import { statusStyles, toneStyles } from './styles';
-/** Below a message this tab sent: sending, or failed with retry and delete. */
+/** Below a message this tab sent that failed: retry and delete. */
export function OutgoingStatus({
message,
onRetry,
@@ -17,17 +17,8 @@ export function OutgoingStatus({
onRetry: (message: ChannelOutgoingMessage) => void;
}) {
const { t } = useTranslation('channel');
- if (message.status === 'sent') return null;
- if (message.status === 'sending')
- return (
- <span
- role="status"
- {...stylex.props(statusStyles.receipts, statusStyles.state, styles.muted)}
- >
- <Icon spin icon={Loader2} size={12} />
- {t('outgoing.sending')}
- </span>
- );
+ // A message still sending shows faded in place (`ChannelMessage` `pending`), with no line here.
+ if (message.status !== 'failed') return null;
return (
<span role="alert" {...stylex.props(statusStyles.receipts, statusStyles.state)}>
<span {...stylex.props(statusStyles.state, toneStyles.error)}>
diff --git a/src/features/Channels/styles.ts b/src/features/Channels/styles.ts
index 26324824848..45842b0cdab 100644
--- a/src/features/Channels/styles.ts
+++ b/src/features/Channels/styles.ts
@@ -64,6 +64,8 @@ export const styles = stylex.create({
},
},
highlightedMessage: { backgroundColor: cssVar.colorInfoBg },
+ /** A message still on its way shows faded instead of carrying a status line. */
+ pendingMessage: { opacity: 0.6 },
messageAvatar: {
position: 'absolute',
insetBlockStart: 8,
diff --git a/src/features/MessageList/AgentConversation.tsx b/src/features/MessageList/AgentConversation.tsx
index 5820d4020be..88271129187 100644
--- a/src/features/MessageList/AgentConversation.tsx
+++ b/src/features/MessageList/AgentConversation.tsx
@@ -93,7 +93,6 @@ const AgentConversation = memo<AgentConversationProps>(({ active, conversation }
active={active}
activeAt={activeAt}
contextMenuItems={menuItems}
- pinned={!!pinned}
preview={preview}
running={running}
title={title}
diff --git a/src/features/MessageList/Body.test.tsx b/src/features/MessageList/Body.test.tsx
index ef5715caacb..c023c518607 100644
--- a/src/features/MessageList/Body.test.tsx
+++ b/src/features/MessageList/Body.test.tsx
@@ -148,6 +148,24 @@ describe('MessageList Body', () => {
expect(screen.queryByText('Loading agents')).not.toBeInTheDocument();
expect(screen.getByText('# Team')).toBeInTheDocument();
});
+
+ // Each pinned row used to paint its own tinted card, so the pinned rows read as separate items.
+ it('renders the pinned rows together in one block', () => {
+ home.isInit = true;
+ home.items = [
+ { id: 'p1', pinned: true, title: 'Pinned 1', type: 'agent', updatedAt: new Date() },
+ { id: 'p2', pinned: true, title: 'Pinned 2', type: 'agent', updatedAt: new Date() },
+ { id: 'a', pinned: false, title: 'Agent A', type: 'agent', updatedAt: new Date() },
+ ];
+
+ render(createElement(Body));
+
+ const group = screen.getByRole('group', { name: 'navPanel.pinned' });
+ expect(group).toHaveTextContent('Pinned 1');
+ expect(group).toHaveTextContent('Pinned 2');
+ expect(group).not.toHaveTextContent('Agent A');
+ expect(group).not.toHaveTextContent('Lobe AI row');
+ });
});
describe('MessageList Body Channel rows', () => {
diff --git a/src/features/MessageList/Body.tsx b/src/features/MessageList/Body.tsx
index ed8f228e965..c6d873e7d5b 100644
--- a/src/features/MessageList/Body.tsx
+++ b/src/features/MessageList/Body.tsx
@@ -34,6 +34,7 @@ import {
buildConversationSections,
channelActivity,
type Conversation,
+ type ConversationEntry,
latestActivity,
latestTopicOf,
} from './conversations';
@@ -161,30 +162,37 @@ const Body = memo(() => {
[items, recents, directChannels, inboxUpdatedAt, inboxTitle, inboxTopic, query, channels],
);
+ // Pinned rows lead the list; they render as one block rather than a card each.
+ const pinnedCount = entries.findIndex((entry) => entry.type !== 'item' || !entry.item.pinned);
+ const pinnedEntries = pinnedCount === -1 ? entries : entries.slice(0, pinnedCount);
+ const otherEntries = pinnedCount === -1 ? [] : entries.slice(pinnedCount);
+
+ const renderEntry = (entry: ConversationEntry) =>
+ entry.type === 'inbox' ? (
+ <InboxConversation activeRouteId={activeRouteId} key={'inbox'} />
+ ) : entry.type === 'channel' ? (
+ <ChannelConversation
+ active={entry.channel.id === activeRouteId}
+ activeAt={entry.activeAt}
+ channel={entry.channel}
+ key={entry.channel.id}
+ />
+ ) : (
+ <ConversationItem activeRouteId={activeRouteId} conversation={entry} key={entry.item.id} />
+ );
+
// Only the agent rows wait on the agent list: Lobe AI and Channels load on
// their own, so a slow or failed agent-list request must not hide them.
const agentsLoading = !isInit && items.length === 0;
return (
<Flexbox gap={1} paddingBlock={'0 12px'} paddingInline={6}>
- {entries.map((entry) =>
- entry.type === 'inbox' ? (
- <InboxConversation activeRouteId={activeRouteId} key={'inbox'} />
- ) : entry.type === 'channel' ? (
- <ChannelConversation
- active={entry.channel.id === activeRouteId}
- activeAt={entry.activeAt}
- channel={entry.channel}
- key={entry.channel.id}
- />
- ) : (
- <ConversationItem
- activeRouteId={activeRouteId}
- conversation={entry}
- key={entry.item.id}
- />
- ),
+ {pinnedEntries.length > 0 && (
+ <div aria-label={t('navPanel.pinned')} role="group" {...stylex.props(styles.pinnedGroup)}>
+ {pinnedEntries.map(renderEntry)}
+ </div>
)}
+ {otherEntries.map(renderEntry)}
{agentsLoading ? (
agentsError ? (
<AsyncError error={agentsError} variant="inline" onRetry={() => void retryAgents()} />
diff --git a/src/features/MessageList/ConversationRow.test.tsx b/src/features/MessageList/ConversationRow.test.tsx
index 53d3e579f34..14277506cc1 100644
--- a/src/features/MessageList/ConversationRow.test.tsx
+++ b/src/features/MessageList/ConversationRow.test.tsx
@@ -71,4 +71,11 @@ describe('ConversationRow', () => {
expect(navigate).not.toHaveBeenCalled();
});
+
+ // A row with no chat yet kept a blank preview line, so its title sat high instead of centered.
+ it('leaves out the preview line when there is no preview', () => {
+ const { row } = renderRow(false);
+
+ expect(row.textContent).toBe('Dario');
+ });
});
diff --git a/src/features/MessageList/ConversationRow.tsx b/src/features/MessageList/ConversationRow.tsx
index 99b8b6d6512..3b60569f051 100644
--- a/src/features/MessageList/ConversationRow.tsx
+++ b/src/features/MessageList/ConversationRow.tsx
@@ -23,8 +23,6 @@ export interface ConversationRowProps {
contextMenuItems?: ComponentProps<typeof ContextMenuTrigger>['items'];
onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
onMouseEnter?: () => void;
- /** Pinned rows keep a tinted background, like WeChat's 置顶. */
- pinned?: boolean;
preview?: string;
/** The row element, e.g. the anchor for an inline rename popover. */
ref?: Ref<HTMLElement>;
@@ -67,7 +65,6 @@ const ConversationRow = memo<ConversationRowProps>(
contextMenuItems,
onClick,
onMouseEnter,
- pinned,
preview,
ref,
running,
@@ -81,7 +78,7 @@ const ConversationRow = memo<ConversationRowProps>(
'aria-current': active ? 'page' : undefined,
'aria-label': title,
ref,
- ...stylex.props(styles.row, pinned && styles.rowPinned, active && styles.rowActive),
+ ...stylex.props(styles.row, active && styles.rowActive),
'to': url,
onClick,
onMouseEnter,
@@ -95,14 +92,20 @@ const ConversationRow = memo<ConversationRowProps>(
<span {...stylex.props(styles.unread)}>{unread > 99 ? '99+' : unread}</span>
)}
</span>
- <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>
+ <Flexbox
+ flex={1}
+ gap={2}
+ justify={'center'}
+ {...stylex.props(styles.rowText, singleLine && styles.rowTextSingleLine)}
+ >
<Flexbox horizontal align={'center'} gap={8}>
<span {...stylex.props(styles.title)}>{title}</span>
{activeAt && (
<span {...stylex.props(styles.time)}>{formatConversationTime(activeAt)}</span>
)}
</Flexbox>
- {!singleLine && (
+ {/* No preview: the title sits centered at the full row height, not over a blank line. */}
+ {!singleLine && (running || preview) && (
<Flexbox horizontal align={'center'} gap={8}>
{running ? (
<Flexbox
@@ -115,7 +118,7 @@ const ConversationRow = memo<ConversationRowProps>(
{t('messageList.running')}
</Flexbox>
) : (
- <span {...stylex.props(styles.preview)}>{preview || ' '}</span>
+ <span {...stylex.props(styles.preview)}>{preview}</span>
)}
</Flexbox>
)}
diff --git a/src/features/MessageList/GroupConversation.tsx b/src/features/MessageList/GroupConversation.tsx
index e8db16458a9..d364978f990 100644
--- a/src/features/MessageList/GroupConversation.tsx
+++ b/src/features/MessageList/GroupConversation.tsx
@@ -44,7 +44,6 @@ const GroupConversation = memo<GroupConversationProps>(({ active, conversation }
active={active}
activeAt={activeAt}
contextMenuItems={contextMenuItems}
- pinned={!!pinned}
preview={preview}
ref={setAnchor}
title={title}
diff --git a/src/features/MessageList/style.ts b/src/features/MessageList/style.ts
index 1541c06ed8a..f4620b37740 100644
--- a/src/features/MessageList/style.ts
+++ b/src/features/MessageList/style.ts
@@ -15,6 +15,14 @@ export const styles = stylex.create({
fontSize: '12px',
color: cssVar.colorTextQuaternary,
},
+ /** Pinned rows share one tinted block, like WeChat's 置顶, instead of a card per row. */
+ pinnedGroup: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: '1px',
+ borderRadius: cssVar.borderRadiusLG,
+ backgroundColor: cssVar.colorFillQuaternary,
+ },
preview: {
overflow: 'hidden',
minWidth: 0,
@@ -34,16 +42,21 @@ export const styles = stylex.create({
paddingBlock: '8px',
paddingInline: '8px',
borderRadius: cssVar.borderRadiusLG,
- color: { default: cssVar.colorText, ':hover': cssVar.colorText },
+ color: { 'default': cssVar.colorText, ':hover': cssVar.colorText },
textDecoration: 'none',
- backgroundColor: { default: null, ':hover': cssVar.colorFillTertiary },
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
transition: 'background-color 0.15s',
},
- rowPinned: {
- backgroundColor: { default: cssVar.colorFillQuaternary, ':hover': cssVar.colorFillTertiary },
- },
rowActive: {
- backgroundColor: { default: cssVar.colorFillSecondary, ':hover': cssVar.colorFillSecondary },
+ backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFillSecondary },
+ },
+ /** Title plus preview line, so a row without a preview keeps the same height. */
+ rowText: {
+ minWidth: 0,
+ minHeight: '36px',
+ },
+ rowTextSingleLine: {
+ minHeight: 0,
},
running: {
color: cssVar.colorSuccess,
diff --git a/src/features/NavRail/style.ts b/src/features/NavRail/style.ts
index 0d919f73a69..28d5add7aa4 100644
--- a/src/features/NavRail/style.ts
+++ b/src/features/NavRail/style.ts
@@ -22,9 +22,10 @@ export const styles = stylex.create({
fontSize: '9px',
fontWeight: 600,
lineHeight: '12px',
- color: cssVar.colorBgContainer,
+ color: '#fff',
textAlign: 'center',
- backgroundColor: cssVar.colorText,
+ // Red like the conversation rows' unread badge, so the count reads as unread, not as a label.
+ backgroundColor: cssVar.colorError,
},
item: {
cursor: 'pointer',
@@ -36,13 +37,13 @@ export const styles = stylex.create({
width: '30px',
height: '30px',
borderRadius: cssVar.borderRadius,
- color: { default: cssVar.colorTextSecondary, ':hover': cssVar.colorText },
- backgroundColor: { default: null, ':hover': cssVar.colorFillTertiary },
+ color: { 'default': cssVar.colorTextSecondary, ':hover': cssVar.colorText },
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillTertiary },
transition: 'color 0.15s, background-color 0.15s',
},
itemActive: {
color: cssVar.colorText,
- backgroundColor: { default: cssVar.colorFillSecondary, ':hover': cssVar.colorFillSecondary },
+ backgroundColor: { 'default': cssVar.colorFillSecondary, ':hover': cssVar.colorFillSecondary },
},
rail: {
userSelect: 'none',