🤯 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
💄 style(sidebar): show contacts as avatar + name and hide direct Agent channels (#22285)
Arvin Xufac53c8899ee
diff --git a/src/features/Channels/channelScope.test.ts b/src/features/Channels/channelScope.test.tsindex f16bf3f4d1e..7f0b44b6791 100644--- a/src/features/Channels/channelScope.test.ts+++ b/src/features/Channels/channelScope.test.ts@@ -3,11 +3,13 @@ import { describe, expect, it } from 'vitest';import { channelsInScope } from './channelScope';const channels = [- { id: 'standalone', projectId: null },- { id: 'launch', projectId: 'pro_1' },- { id: 'other', projectId: 'pro_2' },+ { agentId: null, id: 'standalone', projectId: null },+ { agentId: null, id: 'launch', projectId: 'pro_1' },+ { agentId: null, id: 'other', projectId: 'pro_2' },// Cached before the list carried a project.- { id: 'legacy', projectId: undefined as unknown as null },+ { agentId: null, id: 'legacy', projectId: undefined as unknown as null },+ // A 1:1 conversation with an Agent.+ { agentId: 'agt_1', id: 'direct', projectId: null },];describe('channelsInScope', () => {@@ -19,6 +21,10 @@ describe('channelsInScope', () => {expect(channelsInScope(channels)?.map((c) => c.id)).toEqual(['standalone', 'legacy']);});+ it('leaves direct Agent Channels out of the list', () => {+ expect(channelsInScope(channels)?.map((c) => c.id)).not.toContain('direct');+ });+it('waits for the list to load', () => {expect(channelsInScope(undefined, 'pro_1')).toBeUndefined();});diff --git a/src/features/Channels/channelScope.ts b/src/features/Channels/channelScope.tsindex 25dce4a6a1d..5cef000550c 100644--- a/src/features/Channels/channelScope.ts+++ b/src/features/Channels/channelScope.ts@@ -2,10 +2,14 @@ import type { ChannelListItem } from '@lobechat/types';/*** The Channels one sidebar lists: a project's own, or (without a project) those outside every- * project, so each Channel appears in exactly one place.+ * project, so each Channel appears in exactly one place. A direct (1:1 Agent) Channel is left+ * out: it opens from its Agent's row, not as a group Channel.*/-export const channelsInScope = <T extends Pick<ChannelListItem, 'projectId'>>(+export const channelsInScope = <T extends Pick<ChannelListItem, 'agentId' | 'projectId'>>(channels: T[] | undefined,projectId?: string,): T[] | undefined =>- channels?.filter((channel) => (projectId ? channel.projectId === projectId : !channel.projectId));+ channels?.filter(+ (channel) =>+ !channel.agentId && (projectId ? channel.projectId === projectId : !channel.projectId),+ );diff --git a/src/features/ContactList/index.test.tsx b/src/features/ContactList/index.test.tsxindex a1601bceb1c..61241b228b5 100644--- a/src/features/ContactList/index.test.tsx+++ b/src/features/ContactList/index.test.tsx@@ -2,12 +2,13 @@* @vitest-environment happy-dom*/import { fireEvent, render, screen } from '@testing-library/react';-import { createElement } from 'react';+import { createElement, type ReactNode } from 'react';import { beforeEach, describe, expect, it, vi } from 'vitest';import { ContactListBody } from './index';const fetch = vi.hoisted(() => ({ error: undefined as unknown, mutate: vi.fn() }));+const agentList = vi.hoisted(() => ({ init: false, items: [] as object[] }));vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));vi.mock('@/business/client/hooks/useActiveWorkspaceSlug', () => ({@@ -19,8 +20,16 @@ vi.mock('@/store/home', () => ({useHomeStore: (selector: (state: object) => unknown) => selector({}),}));vi.mock('@/store/home/selectors', () => ({- homeAgentListSelectors: { allAgents: () => [], isAgentListInit: () => false },+ homeAgentListSelectors: {+ allAgents: () => agentList.items,+ isAgentListInit: () => agentList.init,+ },}));+vi.mock('@/features/Workspace/WorkspaceLink', () => ({+ default: ({ children, to, ...rest }: { children: ReactNode; to: string }) =>+ createElement('a', { href: to, ...rest }, children),+}));+vi.mock('@/components/Avatar', () => ({ default: () => createElement('span') }));vi.mock('@/features/NavPanel/components/SkeletonList', () => ({default: () => createElement('div', {}, 'Loading contacts'),}));@@ -30,6 +39,8 @@ vi.mock('@/components/AsyncError', () => ({}));beforeEach(() => {+ agentList.init = false;+ agentList.items = [];fetch.error = undefined;fetch.mutate.mockReset();});@@ -50,4 +61,18 @@ describe('ContactListBody', () => {fireEvent.click(screen.getByText('Retry contacts'));expect(fetch.mutate).toHaveBeenCalled();});++ it('shows each contact as avatar and name only, without the description', () => {+ agentList.init = true;+ agentList.items = [+ { description: 'Turns ideas into product specs', id: 'agt_1', title: 'Product Helper' },+ ];++ render(createElement(ContactListBody));++ expect(screen.getByRole('link', { name: 'Product Helper' })).toHaveTextContent(+ /^Product Helper$/,+ );+ expect(screen.queryByText('Turns ideas into product specs')).not.toBeInTheDocument();+ });});diff --git a/src/features/ContactList/index.tsx b/src/features/ContactList/index.tsxindex 15982bcb707..b23c9dc6e46 100644--- a/src/features/ContactList/index.tsx+++ b/src/features/ContactList/index.tsx@@ -60,8 +60,8 @@ const Contact = memo<{ active: boolean; item: SidebarAgentItem }>(({ active, itereturn (<ConversationRow+ singleLineactive={active}- preview={item.description || undefined}title={title}url={isGroup ? `/group/${item.id}/profile` : `/agent/${item.id}/profile`}avatar={diff --git a/src/features/MessageList/ConversationRow.tsx b/src/features/MessageList/ConversationRow.tsxindex 965978a9706..a759f8b346f 100644--- a/src/features/MessageList/ConversationRow.tsx+++ b/src/features/MessageList/ConversationRow.tsx@@ -23,6 +23,8 @@ export interface ConversationRowProps {/** The row element, e.g. the anchor for an inline rename popover. */ref?: Ref<HTMLElement>;running?: boolean;+ /** Title only, no preview line — for directory lists like the contacts tab. */+ singleLine?: boolean;title: string;unread?: number;url: string;@@ -40,6 +42,7 @@ const ConversationRow = memo<ConversationRowProps>(preview,ref,running,+ singleLine,title,unread,url,@@ -69,21 +72,23 @@ const ConversationRow = memo<ConversationRowProps>(<span {...stylex.props(styles.time)}>{formatConversationTime(activeAt)}</span>)}</Flexbox>- <Flexbox horizontal align={'center'} gap={8}>- {running ? (- <Flexbox- horizontal- align={'center'}- {...stylex.props(styles.preview, styles.running)}- gap={4}- >- <Spin size={10} style={{ color: 'inherit' }} />- {t('messageList.running')}- </Flexbox>- ) : (- <span {...stylex.props(styles.preview)}>{preview || ' '}</span>- )}- </Flexbox>+ {!singleLine && (+ <Flexbox horizontal align={'center'} gap={8}>+ {running ? (+ <Flexbox+ horizontal+ align={'center'}+ {...stylex.props(styles.preview, styles.running)}+ gap={4}+ >+ <Spin size={10} style={{ color: 'inherit' }} />+ {t('messageList.running')}+ </Flexbox>+ ) : (+ <span {...stylex.props(styles.preview)}>{preview || ' '}</span>+ )}+ </Flexbox>+ )}</Flexbox></WorkspaceLink>);