🤯 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(agent): full-width agents list with name, role and responsibility (#21484)
LiJian9411ede364b2
diff --git a/src/components/Skeleton/AgentViewAll.tsx b/src/components/Skeleton/AgentViewAll.tsxindex f92bf1abe5d..0bb11bc2a98 100644--- a/src/components/Skeleton/AgentViewAll.tsx+++ b/src/components/Skeleton/AgentViewAll.tsx@@ -1,6 +1,6 @@'use client';-import { Block, Center, createStaticStyles, cssVar, Flexbox, responsive } from '@lobehub/ui';+import { Block, Center, createStaticStyles, cssVar, Flexbox } from '@lobehub/ui';import WideScreenContainer from '@/features/WideScreenContainer';import type { RouteSkeletonProps } from '@/spa/router/routeMeta';@@ -9,8 +9,10 @@ import { systemStatusSelectors } from '@/store/global/selectors';import SkeletonBar from './Bar';-/** Matches `ACTION_COL_WIDTH` in `features/AgentViewAll/AgentRow.tsx`. */+/** Match `ACTION_COL_WIDTH` / `NAME_COL_WIDTH` / `ROLE_COL_WIDTH` in `features/AgentViewAll/AgentRow.tsx`. */const ACTION_COL_WIDTH = 64;+const NAME_COL_WIDTH = 240;+const ROLE_COL_WIDTH = 200;const styles = createStaticStyles(({ css }) => ({sidebarCard: css`@@ -20,16 +22,10 @@ const styles = createStaticStyles(({ css }) => ({`,sidebarGrid: css`display: grid;- grid-template-columns: repeat(3, minmax(0, 1fr));- gap: 12px;-- ${responsive.md} {- grid-template-columns: repeat(2, minmax(0, 1fr));- }- ${responsive.sm} {- grid-template-columns: minmax(0, 1fr);- }+ /* Full-width page: as many 280px+ columns as fit, one column on narrow screens. */+ grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));+ gap: 12px;`,sidebarSection: css`padding: 12px;@@ -82,7 +78,8 @@ export const AgentViewAllSidebarSectionSkeleton = () => {/*** Dense `AgentRow`s of the default list view (`agentListViewMode: 'list'`,- * `groupBy: 'none'`): padding 8/12, 28px square avatar + 14px name, then the+ * `groupBy: 'none'`): padding 8/12, 28px square avatar, then the name / role /+ * description columns, then the* right-aligned 88px update-time column and the 64px eye / "…" action column.* Also the page's own loading state while the agent list initialises.*/@@ -92,7 +89,15 @@ export const AgentViewAllRowsSkeleton = ({ rows = 8 }: { rows?: number }) => (<Flexbox horizontal align={'center'} gap={12} key={index} paddingBlock={8} paddingInline={12}><Flexbox horizontal align={'center'} flex={1} gap={12} style={{ minWidth: 0 }}><SkeletonBar height={28} width={28} />- <SkeletonBar height={14} width={`${18 + (index % 4) * 6}%`} />+ <Flexbox flex={'0 1 auto'} style={{ minWidth: 0, width: NAME_COL_WIDTH }}>+ <SkeletonBar height={14} width={`${50 + (index % 4) * 10}%`} />+ </Flexbox>+ <Flexbox flex={'0 1 auto'} style={{ minWidth: 0, width: ROLE_COL_WIDTH }}>+ <SkeletonBar height={12} width={`${40 + (index % 3) * 15}%`} />+ </Flexbox>+ <Flexbox flex={1} style={{ minWidth: 0 }}>+ <SkeletonBar height={12} width={`${30 + (index % 5) * 8}%`} />+ </Flexbox></Flexbox><Flexbox align={'flex-end'} flex={'none'} style={{ minWidth: 88 }}><SkeletonBar height={12} width={56} />@@ -111,7 +116,7 @@ export const AgentViewAllRowsSkeleton = ({ rows = 8 }: { rows?: number }) => (/*** Route-level skeleton for `/agents` (`features/AgentViewAll/AgentViewAllPage.tsx`):- * the 44px header (title left, list-config icon right), then the 960px column+ * the 44px header (title left, list-config icon right), then the full-width column* with the "In sidebar" block and the toolbar (240px-max search left, split* create button right) over the default list view's rows.*/@@ -132,7 +137,7 @@ const AgentViewAllSkeleton = ({ chrome = 'page' }: RouteSkeletonProps) => (<SkeletonBar height={28} width={28} /></Flexbox>)}- <WideScreenContainer gap={16} paddingBlock={16}>+ <WideScreenContainer fullWidth gap={16} paddingBlock={16} paddingInline={16}><AgentViewAllSidebarSectionSkeleton /><Flexbox horizontal align={'center'} gap={12} justify={'space-between'}><SkeletonBar height={32} width={206} />diff --git a/src/features/AgentViewAll/AgentCard.tsx b/src/features/AgentViewAll/AgentCard.tsxindex 0743a13a9c6..7463dc9375d 100644--- a/src/features/AgentViewAll/AgentCard.tsx+++ b/src/features/AgentViewAll/AgentCard.tsx@@ -10,7 +10,6 @@ import {createStaticStyles,type DropdownItem,Flexbox,- responsive,Tag,Text,Tooltip,@@ -59,19 +58,13 @@ export const cardStyles = createStaticStyles(({ css, cssVar }) => ({`,grid: css`display: grid;- grid-template-columns: repeat(3, minmax(0, 1fr));++ /* Full-width page: as many 280px+ columns as fit, one column on narrow screens. */+ grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));gap: 12px;width: 100%;min-width: 0;-- ${responsive.md} {- grid-template-columns: repeat(2, minmax(0, 1fr));- }-- ${responsive.sm} {- grid-template-columns: minmax(0, 1fr);- }`,/* Top-right "…" slot, a SIBLING of the card link (absolutely positionedover it) — nesting an interactive menu trigger inside the <a> would putdiff --git a/src/features/AgentViewAll/AgentRow.test.tsx b/src/features/AgentViewAll/AgentRow.test.tsxnew file mode 100644index 00000000000..ba45b5ecc4f--- /dev/null+++ b/src/features/AgentViewAll/AgentRow.test.tsx@@ -0,0 +1,60 @@+/**+ * @vitest-environment happy-dom+ */+import type { SidebarAgentItem } from '@lobechat/types';+import { render, screen } from '@testing-library/react';+import { type ReactNode } from 'react';+import { describe, expect, it, vi } from 'vitest';++import AgentRow from './AgentRow';++vi.mock('react-i18next', () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++vi.mock('@/features/Workspace/WorkspaceLink', () => ({+ default: ({ children, className }: { children: ReactNode; className?: string }) => (+ <a className={className} data-testid={'identity-link'} href={'#'}>+ {children}+ </a>+ ),+}));++vi.mock('./AgentAvatar', () => ({ default: () => <span /> }));+vi.mock('./ItemActions', () => ({ default: () => <button type={'button'}>more</button> }));++const baseItem = {+ id: 'agt_cook',+ pinned: false,+ type: 'agent',+ // Older than 7 days, so the row prints a plain date instead of a relative one.+ updatedAt: new Date('2026-01-01T00:00:00Z'),+} as unknown as SidebarAgentItem;++describe('AgentRow', () => {+ it('shows the name, role and responsibility as columns inside the identity link', () => {+ render(+ <AgentRow+ item={{+ ...baseItem,+ description: 'Reviews and merges community PRs',+ name: 'Cook',+ title: '公共CC(美国 100刀)',+ }}+ />,+ );++ const link = screen.getByTestId('identity-link');+ expect(link.textContent).toContain('Cook');+ expect(link.textContent).toContain('公共CC(美国 100刀)');+ expect(link.textContent).toContain('Reviews and merges community PRs');+ });++ it('leaves the role column empty when the title is already the primary label', () => {+ render(<AgentRow item={{ ...baseItem, description: null, title: 'LobeHub' }} />);++ const link = screen.getByTestId('identity-link');+ expect(screen.getAllByText('LobeHub')).toHaveLength(1);+ expect(link.textContent).toBe('LobeHub');+ });+});diff --git a/src/features/AgentViewAll/AgentRow.tsx b/src/features/AgentViewAll/AgentRow.tsxindex a0b41aef8d0..4eb9f5674da 100644--- a/src/features/AgentViewAll/AgentRow.tsx+++ b/src/features/AgentViewAll/AgentRow.tsx@@ -4,7 +4,7 @@ import { AGENT_CHAT_URL, DEFAULT_AVATAR, GROUP_CHAT_URL } from '@lobechat/const'import type { SidebarAgentItem } from '@lobechat/types';import { agentDisplayName, agentSecondaryDisplayName } from '@lobechat/types';import { ContextMenuTrigger, type DropdownItem, Flexbox, Tooltip } from '@lobehub/ui';-import { ActionIcon, Avatar, createStaticStyles, cssVar, Text } from '@lobehub/ui';+import { ActionIcon, Avatar, createStaticStyles, cssVar, cx, Text } from '@lobehub/ui';import dayjs from 'dayjs';import { EyeIcon, EyeOffIcon } from 'lucide-react';import { memo, type MouseEvent, useCallback, useRef, useState } from 'react';@@ -22,16 +22,29 @@ export const ACTION_COL_WIDTH = 64;/** Author avatar slot — reserved even when the author is unknown. */const AUTHOR_COL_WIDTH = 20;+/** Name and role column widths, shared by every row so the columns line up. */+export const NAME_COL_WIDTH = 240;+export const ROLE_COL_WIDTH = 200;+const styles = createStaticStyles(({ css, cssVar }) => ({- // Second line, so name, role and description no longer compete for one- // line; rows without a description stay single-line.+ /**+ * Fills the rest of the identity link and truncates to one line. Its minimum+ * makes the name and role columns give up width first on mid-size screens;+ * only a row too narrow for all three drops it.+ */description: css`- line-height: 18px;+ flex: 1 1 0;+ min-width: 180px;+ color: ${cssVar.colorTextTertiary};++ @container agent-row (width < 600px) {+ display: none;+ }`,- // The link spans the name column (not the whole row) — a management list- // is for scanning and acting, and a full-row link turns clicks on the- // author / timestamp / action columns into a navigation. The name column- // stays a generous target, including the space right of a short title.+ // The link spans the identity columns (name, role, description) but not the+ // whole row — a management list is for scanning and acting, and a full-row+ // link turns clicks on the author / timestamp / action columns into a+ // navigation.identity: css`cursor: pointer;@@ -48,16 +61,32 @@ const styles = createStaticStyles(({ css, cssVar }) => ({text-decoration: underline;}`,- // Plain secondary text (as in the sidebar), not a filled tag: a tag weighed- // as much as the name. Shrinks before the name, so the name stays readable.+ name: css`+ flex: 0 1 ${NAME_COL_WIDTH}px;+ min-width: 0;++ /* Without the description, name and role share the space 3:2. */+ @container agent-row (width < 600px) {+ flex: 3 1 0;+ }+ `,+ /** Reserved even when empty so every row's description starts at the same x. */role: css`- flex: 0 10 auto;+ flex: 0 1 ${ROLE_COL_WIDTH}px;min-width: 0;+ color: ${cssVar.colorTextSecondary};++ @container agent-row (width < 600px) {+ flex: 2 1 0;+ }`,row: css`+ container: agent-row / inline-size;+padding-block: 8px;padding-inline: 12px;border-radius: ${cssVar.borderRadiusLG};+color: inherit;&:hover {@@ -114,7 +143,7 @@ const AgentRow = memo<AgentRowProps>(const { description, id, type, updatedAt } = item;// Groups have no personal name, so this resolves to their title.const displayTitle = agentDisplayName(item, t('agentViewAll.untitled'));- const roleTag = agentSecondaryDisplayName(item);+ const role = agentSecondaryDisplayName(item);const [anchor, setAnchor] = useState<HTMLElement | null>(null);// Right-click support (Task-List-style): the hook-bearing menu mounts on@@ -152,36 +181,17 @@ const AgentRow = memo<AgentRowProps>(to={type === 'group' ? GROUP_CHAT_URL(id) : AGENT_CHAT_URL(id, false)}><AgentAvatar item={item} size={28} />- <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>- <Flexbox horizontal align={'baseline'} gap={8} style={{ minWidth: 0 }}>- <Text ellipsis className={'agent-row-title'} weight={500}>- {displayTitle}- </Text>- {roleTag ? (- <Text- ellipsis- className={styles.role}- fontSize={12}- title={roleTag}- type={'secondary'}- >- {roleTag}- </Text>- ) : null}- </Flexbox>- {description ? (- <Text- ellipsis- className={styles.description}- fontSize={12}- // Inline: Text's own color class would otherwise win.- style={{ color: cssVar.colorTextTertiary }}- title={description}- >- {description}- </Text>- ) : null}- </Flexbox>+ {/* Three single-line columns: who the agent is, the role it plays,+ and what it is responsible for. */}+ <Text ellipsis className={cx('agent-row-title', styles.name)} weight={500}>+ {displayTitle}+ </Text>+ <Text ellipsis className={styles.role} title={role}>+ {role}+ </Text>+ <Text ellipsis className={styles.description} title={description ?? undefined}>+ {description}+ </Text></WorkspaceLink>{/* Trailing cluster (Task-list-style): label pills + author avatar +update time as one tight right-aligned group. */}diff --git a/src/features/AgentViewAll/AgentViewAllPage.tsx b/src/features/AgentViewAll/AgentViewAllPage.tsxindex 3e4f7afdec8..4ec3c28f851 100644--- a/src/features/AgentViewAll/AgentViewAllPage.tsx+++ b/src/features/AgentViewAll/AgentViewAllPage.tsx@@ -535,7 +535,13 @@ const AgentViewAllPage = memo(() => {/>}/>- <WideScreenContainer gap={16} paddingBlock={16} wrapperStyle={{ flex: 1, overflowY: 'auto' }}>+ <WideScreenContainer+ fullWidth+ gap={16}+ paddingBlock={16}+ paddingInline={16}+ wrapperStyle={{ flex: 1, overflowY: 'auto' }}+ >{!isInit && !keyword.trim() && <AgentViewAllSidebarSectionSkeleton />}{isInit && !keyword.trim() && sidebarItems.length > 0 && (<SidebarAgentsSection items={sidebarItems} onToggleSidebar={handleToggleSidebar} />diff --git a/src/features/AgentViewAll/SidebarAgentsSection.tsx b/src/features/AgentViewAll/SidebarAgentsSection.tsxindex d0efe68728c..7e3723c1a5a 100644--- a/src/features/AgentViewAll/SidebarAgentsSection.tsx+++ b/src/features/AgentViewAll/SidebarAgentsSection.tsx@@ -4,7 +4,7 @@ import { AGENT_CHAT_URL, GROUP_CHAT_URL } from '@lobechat/const';import type { SidebarAgentItem } from '@lobechat/types';import { agentDisplayName, agentSecondaryDisplayName } from '@lobechat/types';import { Block, ContextMenuTrigger, type DropdownItem, Flexbox, Icon } from '@lobehub/ui';-import { createStaticStyles, cssVar, responsive, Tag, Text } from '@lobehub/ui';+import { createStaticStyles, cssVar, Tag, Text } from '@lobehub/ui';import { ChevronDownIcon, ChevronUpIcon } from 'lucide-react';import { memo, useCallback, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -67,19 +67,13 @@ const styles = createStaticStyles(({ css, cssVar }) => ({`,grid: css`display: grid;- grid-template-columns: repeat(3, minmax(0, 1fr));++ /* Full-width page: as many 280px+ columns as fit, one column on narrow screens. */+ grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));gap: 12px;width: 100%;min-width: 0;-- ${responsive.md} {- grid-template-columns: repeat(2, minmax(0, 1fr));- }-- ${responsive.sm} {- grid-template-columns: minmax(0, 1fr);- }`,header: css`cursor: pointer;