🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(messages): list joined project Channels and badge the Messages tab by its rows (#22897)
Arvin Xu619ab2c3f393
diff --git a/src/features/MessageList/Body.test.tsx b/src/features/MessageList/Body.test.tsxindex d394e2ad8f0..18331c81c5a 100644--- a/src/features/MessageList/Body.test.tsx+++ b/src/features/MessageList/Body.test.tsx@@ -38,6 +38,11 @@ vi.mock('@/store/channel', () => ({channelSelectors: { list: () => home.channels },useChannelStore: (selector: (state: object) => unknown) => selector({}),}));+vi.mock('@/store/project', () => ({+ useCurrentProjectList: () => [{ avatar: null, id: 'pro_1', name: 'Apollo' }],+ useProjectStore: (selector: (state: object) => unknown) =>+ selector({ useFetchProjectList: () => ({}) }),+}));vi.mock('@/features/Channels/useChannelsEnabled', () => ({useChannelsEnabled: () => home.channelsEnabled,}));@@ -255,7 +260,7 @@ describe('MessageList Body Channel rows', () => {...patch,});- it('lists group Channels as rows, leaving out direct, project and archived ones', () => {+ it('lists group and project Channels as rows, leaving out direct and archived ones', () => {home.channels = [channel({ id: 'chn_team', title: 'Team' }),channel({ agentId: 'agt_nasa', id: 'chn_direct', title: 'Nasa' }),@@ -267,7 +272,7 @@ describe('MessageList Body Channel rows', () => {expect(screen.getByText('# Team')).toBeInTheDocument();expect(screen.queryByText('# Nasa')).not.toBeInTheDocument();- expect(screen.queryByText('# Project')).not.toBeInTheDocument();+ expect(screen.getByText('# Project')).toBeInTheDocument();expect(screen.queryByText('# Old')).not.toBeInTheDocument();});diff --git a/src/features/MessageList/Body.tsx b/src/features/MessageList/Body.tsxindex 1a52d5430f6..b1174cdd623 100644--- a/src/features/MessageList/Body.tsx+++ b/src/features/MessageList/Body.tsx@@ -26,6 +26,7 @@ import { useHomeStore } from '@/store/home';import { homeAgentListSelectors, homeRecentSelectors } from '@/store/home/selectors';import { ALL_RECENTS_LIMIT } from '@/store/home/slices/recent/action';import { createConversationRecentQueryKey } from '@/store/home/slices/recent/projection';+import { useCurrentProjectList, useProjectStore } from '@/store/project';import AgentConversation from './AgentConversation';import ChannelConversation from './ChannelConversation';@@ -113,11 +114,17 @@ const Body = memo(() => {}, [activeRouteId, revalidateRecents]);const channelsEnabled = useChannelsEnabled();const allChannels = useChannelStore(channelSelectors.list);+ useProjectStore((s) => s.useFetchProjectList)(channelsEnabled);+ const projects = useCurrentProjectList();+ const projectMap = useMemo(+ () => new Map(projects.map((project) => [project.id, project] as const)),+ [projects],+ );const { query } = useMessageSearch();const [showArchived, setShowArchived] = useState(false);- // Group Channels outside any project; a direct Channel opens from its Agent's row. An archived- // one leaves the list unless it is open, but search still finds it and the archived group at- // the end lists it.+ // Group Channels, a project's included as that project's group chat; a direct Channel opens+ // from its Agent's row. An archived one leaves the list unless it is open, but search still+ // finds it and the archived group at the end lists it.const directChannels = useMemo(() =>new Map(@@ -130,9 +137,7 @@ const Body = memo(() => {[allChannels, channelsEnabled],);const { archived, channels } = useMemo(() => {- const groups = channelsEnabled- ? (allChannels ?? []).filter((channel) => !channel.projectId && !channel.agentId)- : [];+ const groups = channelsEnabled ? (allChannels ?? []).filter((channel) => !channel.agentId) : [];const isHidden = (channel: (typeof groups)[number]) =>channel.status === 'archived' && channel.id !== activeRouteId;return {@@ -177,6 +182,7 @@ const Body = memo(() => {},query,channels,+ (channel) => (channel.projectId ? projectMap.get(channel.projectId)?.name : undefined),),[items,@@ -189,6 +195,7 @@ const Body = memo(() => {inboxChannel,query,channels,+ projectMap,],);diff --git a/src/features/MessageList/ChannelConversation.tsx b/src/features/MessageList/ChannelConversation.tsxindex f08c11fcbdb..bf076ea41bb 100644--- a/src/features/MessageList/ChannelConversation.tsx+++ b/src/features/MessageList/ChannelConversation.tsx@@ -4,6 +4,7 @@ import { CHANNEL_URL } from '@lobechat/const';import type { ChannelListItem } from '@lobechat/types';import { Avatar, Icon } from '@lobehub/ui';import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';+import * as stylex from '@stylexjs/stylex';import { HashIcon } from 'lucide-react';import { memo } from 'react';@@ -13,7 +14,7 @@ import { projectListItemSelector, useProjectStore } from '@/store/project';import ConversationRow from './ConversationRow';import { channelPreview } from './conversations';-import { AVATAR_SIZE } from './style';+import { AVATAR_SIZE, styles } from './style';interface ChannelConversationProps {active: boolean;@@ -34,17 +35,23 @@ const ChannelConversation = memo<ChannelConversationProps>(({ active, activeAt,activeAt={activeAt}contextMenuItems={menuItems(channel)}preview={channelPreview(channel)}+ tag={project?.name}title={channel.title}unread={channel.unreadCount}url={CHANNEL_URL(channel.id)}avatar={project ? (- <ProjectAvatar- avatar={project.avatar}- id={project.id}- name={project.name}- size={AVATAR_SIZE}- />+ <>+ <ProjectAvatar+ avatar={project.avatar}+ id={project.id}+ name={project.name}+ size={AVATAR_SIZE}+ />+ <span {...stylex.props(styles.channelMark)}>+ <Icon color={cssVar.colorTextSecondary} icon={HashIcon} size={9} />+ </span>+ </>) : (<Avataravatar={<Icon color={cssVar.colorTextSecondary} icon={HashIcon} size={16} />}diff --git a/src/features/MessageList/ConversationRow.tsx b/src/features/MessageList/ConversationRow.tsxindex 591c9058c94..a5828c08df3 100644--- a/src/features/MessageList/ConversationRow.tsx+++ b/src/features/MessageList/ConversationRow.tsx@@ -30,6 +30,8 @@ export interface ConversationRowProps {ref?: Ref<HTMLElement>;/** Title only, no preview line — for directory lists like the contacts tab. */singleLine?: boolean;+ /** A muted label after the title, e.g. the project a Channel belongs to. */+ tag?: string;title: string;/** The Agent is replying: the preview line says "typing" like the conversation header. */typing?: boolean;@@ -71,6 +73,7 @@ const ConversationRow = memo<ConversationRowProps>(preview,ref,singleLine,+ tag,title,typing,unread,@@ -102,7 +105,10 @@ const ConversationRow = memo<ConversationRowProps>({...stylex.props(styles.rowText, singleLine && styles.rowTextSingleLine)}><Flexbox horizontal align={'center'} gap={8}>- <span {...stylex.props(styles.title)}>{title}</span>+ <span {...stylex.props(styles.title)}>+ {title}+ {tag && <span {...stylex.props(styles.tag)}>{tag}</span>}+ </span>{activeAt && (<span {...stylex.props(styles.time)}>{formatConversationTime(activeAt)}</span>)}diff --git a/src/features/MessageList/conversations.test.ts b/src/features/MessageList/conversations.test.tsindex 4d32d17f821..7a1fca547b8 100644--- a/src/features/MessageList/conversations.test.ts+++ b/src/features/MessageList/conversations.test.ts@@ -8,6 +8,7 @@ import {inboxActivity,latestActivity,latestTopicOf,+ messagesUnreadCount,} from './conversations';const agent = (id: string, updatedAt: string, extra: Partial<SidebarAgentItem> = {}) =>@@ -250,6 +251,55 @@ describe('buildConversationEntries', () => {'chn_team',]);});++ it("finds a project Channel by its project's name", () => {+ const channels = [+ { ...channel('chn_general', 'General', '2026-10-03'), projectId: 'pro_1' },+ channel('chn_team', 'Team', '2026-10-02'),+ ];+ const projectNameOf = (c: ChannelListItem) => (c.projectId ? 'Apollo' : undefined);++ expect(+ ids(buildConversationEntries(sections, undefined, 'apollo', channels, projectNameOf)),+ ).toEqual(['chn_general']);+ });+});++describe('messagesUnreadCount', () => {+ const channel = (patch: Partial<ChannelListItem>) =>+ ({+ agentId: null,+ projectId: null,+ status: 'active',+ unreadCount: 0,+ ...patch,+ }) as ChannelListItem;++ it('sums the list rows: topics without a direct Channel, direct, group and project Channels', () => {+ const items = [+ agent('agt_topics', '2026-10-01', { unreadCount: 2 }),+ agent('agt_direct', '2026-10-01', { unreadCount: 5 }),+ ];+ const channels = [+ channel({ agentId: 'agt_direct', id: 'chn_direct', unreadCount: 1 }),+ channel({ agentId: 'agt_inbox', id: 'chn_inbox', unreadCount: 3 }),+ channel({ id: 'chn_team', unreadCount: 4 }),+ channel({ id: 'chn_project', projectId: 'pro_1', unreadCount: 6 }),+ ];++ // 2 (topics) + 1 (direct, not the agent's 5 topics) + 3 (inbox) + 4 (group) + 6 (project)+ expect(messagesUnreadCount(items, channels)).toBe(16);+ });++ it('leaves out archived group Channels, which have no row', () => {+ const channels = [channel({ id: 'chn_old', status: 'archived', unreadCount: 7 })];++ expect(messagesUnreadCount([], channels)).toBe(0);+ });++ it('counts only Agent topics while Channels are off', () => {+ expect(messagesUnreadCount([agent('a', '2026-10-01', { unreadCount: 2 })], undefined)).toBe(2);+ });});describe('latestTopicOf', () => {diff --git a/src/features/MessageList/conversations.ts b/src/features/MessageList/conversations.tsindex f004ae426fc..5c2a2181a9c 100644--- a/src/features/MessageList/conversations.ts+++ b/src/features/MessageList/conversations.ts@@ -181,6 +181,8 @@ export const buildConversationEntries = (inbox: { activeAt?: Date; channel?: ChannelListItem; title: string } | undefined,query = '',channels: ChannelListItem[] = [],+ /** The name of the project a Channel belongs to, which a search also matches. */+ projectNameOf?: (channel: ChannelListItem) => string | undefined,): ConversationEntry[] => {const keyword = query.trim().toLowerCase();const matches = (...names: (string | null | undefined)[]) =>@@ -196,7 +198,7 @@ export const buildConversationEntries = (const rest = [...items(recent),...channels- .filter((channel) => matches(channel.title))+ .filter((channel) => matches(channel.title, projectNameOf?.(channel))).map((channel) => ({activeAt: channelActivity(channel),channel,@@ -216,6 +218,29 @@ export const buildConversationEntries = (return [...items(pinned), ...rest];};+/**+ * The Messages tab badge: the sum of what the list rows show. A row that opens a direct Channel+ * counts that Channel's unread messages instead of its Agent's unread topics, and an archived+ * group Channel has no row.+ */+export const messagesUnreadCount = (+ items: Pick<SidebarAgentItem, 'id' | 'unreadCount'>[],+ channels: ChannelListItem[] | undefined,+): number => {+ let sum = 0;+ const directAgentIds = new Set<string>();+ for (const channel of channels ?? []) {+ const direct = !!channel.agentId && !channel.projectId;+ if (direct) directAgentIds.add(channel.agentId!);+ else if (channel.agentId || channel.status === 'archived') continue;+ sum += channel.unreadCount ?? 0;+ }+ for (const item of items) {+ if (!directAgentIds.has(item.id)) sum += item.unreadCount ?? 0;+ }+ return sum;+};+/** IM-style timestamp: time today, weekday this week, date otherwise. */export const formatConversationTime = (date: Date, now: Date = new Date()): string => {const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();diff --git a/src/features/MessageList/style.ts b/src/features/MessageList/style.tsindex 6092c215efe..7c0c989bedc 100644--- a/src/features/MessageList/style.ts+++ b/src/features/MessageList/style.ts@@ -9,6 +9,22 @@ export const styles = stylex.create({display: 'inline-flex',flex: 'none',},+ /** Marks a project avatar as one of that project's Channels. */+ channelMark: {+ position: 'absolute',+ insetBlockEnd: '-3px',+ insetInlineEnd: '-3px',+ display: 'inline-flex',+ alignItems: 'center',+ justifyContent: 'center',+ width: '14px',+ height: '14px',+ borderWidth: '1.5px',+ borderStyle: 'solid',+ borderColor: cssVar.colorBgContainer,+ borderRadius: '4px',+ backgroundColor: cssVar.colorBgElevated,+ },empty: {paddingBlock: '8px',paddingInline: '10px',@@ -58,6 +74,12 @@ export const styles = stylex.create({rowTextSingleLine: {minHeight: 0,},+ tag: {+ marginInlineStart: '6px',+ fontSize: '11px',+ fontWeight: 400,+ color: cssVar.colorTextQuaternary,+ },time: {flex: 'none',fontSize: '11px',diff --git a/src/features/NavRail/index.tsx b/src/features/NavRail/index.tsxindex 4b46974f0f1..6393e357993 100644--- a/src/features/NavRail/index.tsx+++ b/src/features/NavRail/index.tsx@@ -16,10 +16,13 @@ import { useTranslation } from 'react-i18next';import { useActiveWorkspaceSlug } from '@/business/client/hooks/useActiveWorkspaceSlug';import { isDesktop } from '@/const/version';+import { useChannelsEnabled } from '@/features/Channels/useChannelsEnabled';import { MAC_VIBRANCY_BACKGROUND } from '@/features/Electron/system/macWindowFullscreen';import InboxButton from '@/features/HomeSidebar/Header/components/InboxButton';import User from '@/features/HomeSidebar/Header/components/User';+import { messagesUnreadCount } from '@/features/MessageList/conversations';import { useActiveLocation } from '@/hooks/useActiveLocation';+import { channelSelectors, useChannelStore } from '@/store/channel';import { useHomeStore } from '@/store/home';import { homeAgentListSelectors } from '@/store/home/selectors';import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';@@ -36,10 +39,16 @@ const railBackground = {background: isDesktop && isMacOS() ? MAC_VIBRANCY_BACKGROUND : cssVar.colorBgLayout,};-const useMessagesUnread = () =>- useHomeStore((s) =>- homeAgentListSelectors.allAgents(s).reduce((sum, item) => sum + (item.unreadCount ?? 0), 0),+/** The badge sums the Messages list rows, so it always matches what the list shows. */+const useMessagesUnread = (channelsEnabled: boolean) => {+ const channels = useChannelStore(channelSelectors.list);+ return useHomeStore((s) =>+ messagesUnreadCount(+ homeAgentListSelectors.allAgents(s),+ channelsEnabled ? channels : undefined,+ ),);+};/*** Global icon rail (column ①). Tabs own a list column (column ②) registered@@ -50,7 +59,8 @@ const NavRail = memo(() => {const { pathname } = useActiveLocation();const activeWorkspaceSlug = useActiveWorkspaceSlug();const { showMarket } = useServerConfigStore(featureFlagsSelectors);- const unread = useMessagesUnread();+ const channelsEnabled = useChannelsEnabled();+ const unread = useMessagesUnread(channelsEnabled);const activeTab = resolveRailTab(pathname, activeWorkspaceSlug);@@ -71,7 +81,8 @@ const NavRail = memo(() => {return (<Flexbox className={stylex.props(styles.rail).className} gap={12} style={railBackground}>- {activeChannelId && <ActiveChannelSync />}+ {/* The badge counts Channel rows, so the list stays fresh whenever Channels are on. */}+ {(activeChannelId || channelsEnabled) && <ActiveChannelSync />}<User lite /><Flexbox align={'center'} gap={RAIL_GAP}>{topItems.map((item) => (diff --git a/src/features/NavRail/messagesTarget.ts b/src/features/NavRail/messagesTarget.tsindex b88cd929da3..fe17e2b2a2a 100644--- a/src/features/NavRail/messagesTarget.ts+++ b/src/features/NavRail/messagesTarget.ts@@ -11,8 +11,8 @@ const scopedSegments = (pathname: string, activeWorkspaceSlug: string | null) =>/*** The Channel the Messages tab returns to after `pathname` is visited. Opening a Channel makes it- * the active one; going back home clears it; any other page keeps the previous one. A project's- * Channel belongs to the Projects tab, so it is ignored.+ * the active one; going back home clears it; any other page keeps the previous one. A project+ * Channel opened from the Projects tab (`/project/:id/channels/:id`) is not tracked.*/export const nextActiveChannelId = (previous: string | undefined,