Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(bots): 收紧伙伴列表并统一时间、离线提示与群头像

Dash24fb8ef75b04
diff --git a/apps/desktop/src/renderer/features/bots/BotConnectionStatus.tsx b/apps/desktop/src/renderer/features/bots/BotConnectionStatus.tsx
index f8c1710bb2..e5445d524d 100644
--- a/apps/desktop/src/renderer/features/bots/BotConnectionStatus.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotConnectionStatus.tsx
@@ -16,24 +16,26 @@ export function BotConnectionStatus({
className?: string;
}) {
const { t } = useTranslation();
- const status = t(homeOffline && !online ? 'bots.cloud.homeOfflineShort'
- : online === null ? 'bots.remote.unknown' : online ? 'bots.remote.online' : 'bots.remote.offline');
+ const offline = online === false;
+ const status = offline ? t(homeOffline ? 'bots.cloud.homeOfflineShort' : 'bots.remote.offline') : '';
const name = deviceName?.trim();
- const label = name ? `${status} · ${name}` : status;
+ const label = [status, name].filter(Boolean).join(' · ');
if (inline) {
+ if (!label) return null;
return (
<span title={label} className={cn('min-w-0 truncate text-11 leading-normal', className)}>
{label}
</span>
);
}
+ if (!offline) return null;
return (
<span
aria-hidden="true"
title={label}
className={cn(
'absolute bottom-0 right-0 h-2.5 w-2.5 rounded-full border-2 border-sidebar',
- online === null ? 'bg-[var(--text-tertiary)]' : online ? 'bg-[var(--remote-status-ready)]' : 'bg-[var(--remote-status-failed)]',
+ 'bg-[var(--remote-status-failed)]',
)}
/>
);
diff --git a/apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx b/apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx
index 8659858b48..b42d0d4594 100644
--- a/apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx
@@ -1,7 +1,7 @@
/**
- * 群的身份标记:侧栏行用两位成员的叠放头像,顶栏与群设置用一排叠放头像。
+ * 群的身份标记:侧栏按人数显示组合头像,顶栏与群设置用一排叠放头像。
* 每个头像仍是 BotAvatar(同一套 `--bot-avatar-*` 色板),叠放处用和底色同色的
- * 2px 描边隔开——与在线状态点 `border-sidebar` 的做法一致,不引入阴影或新 token。
+ * 描边隔开——与离线状态点 `border-sidebar` 的做法一致,不引入阴影或新 token。
*/
import { Users } from 'lucide-react';
@@ -11,36 +11,86 @@ import { BotAvatar } from './BotAvatar';
type AvatarMember = Pick<BotGroupMemberView, 'botId' | 'name' | 'avatar' | 'avatarColor'>;
-/** 40px sidebar mark: the first two members, offset diagonally. */
-export function BotGroupDuoAvatar({
+/** 固定头像区域:双人斜向叠放,多人错位重叠,描边区分前后层次。 */
+export function BotGroupSidebarAvatar({
members,
selected = false,
+ compact = false,
}: {
members: readonly AvatarMember[];
selected?: boolean;
+ compact?: boolean;
}) {
+ const frameClass = compact ? 'h-7 w-7' : 'h-10 w-10';
const [first, second] = members;
if (!first) {
return (
<span
aria-hidden
- className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[var(--surface-chip)] text-[var(--text-tertiary)]"
+ className={cn(
+ 'flex shrink-0 items-center justify-center rounded-full bg-[var(--surface-chip)] text-[var(--text-tertiary)]',
+ frameClass,
+ )}
>
<Users size={16} />
</span>
);
}
- if (!second) return <BotAvatar bot={first} size="md" />;
+ if (!second) return <BotAvatar bot={first} size={compact ? 'sm' : 'md'} />;
+ if (members.length >= 3) {
+ const positions =
+ members.length === 3
+ ? ['left-0 top-0', 'right-0 top-[15%]', 'bottom-0 left-[15%]']
+ : ['left-0 top-0', 'right-0 top-[5%]', 'bottom-[5%] left-0', 'bottom-0 right-0'];
+ return (
+ <span aria-hidden className={cn('relative flex shrink-0', frameClass)}>
+ {members.slice(0, 4).map((member, index) => (
+ <span
+ key={member.botId}
+ className={cn(
+ 'absolute flex rounded-full',
+ compact ? 'border-[1.5px]' : 'border-2',
+ members.length === 3 ? 'h-[65%] w-[65%]' : 'h-[60%] w-[60%]',
+ selected
+ ? 'border-sidebar-item-active'
+ : 'border-sidebar group-hover:border-sidebar-item-hover',
+ positions[index],
+ )}
+ >
+ <BotAvatar
+ bot={member}
+ size="xs"
+ className={cn('h-full w-full', compact ? 'text-10' : 'text-12')}
+ />
+ </span>
+ ))}
+ </span>
+ );
+ }
return (
- <span aria-hidden className="relative h-10 w-10 shrink-0">
- <BotAvatar bot={first} size="xs" className="absolute left-0.5 top-0.5 h-6 w-6 text-12" />
+ <span aria-hidden className={cn('relative flex shrink-0', frameClass)}>
+ <BotAvatar
+ bot={first}
+ size="xs"
+ className={cn(
+ 'absolute',
+ compact ? 'left-0 top-0 h-[18px] w-[18px] text-10' : 'left-0.5 top-0.5 h-6 w-6 text-12',
+ )}
+ />
<span
className={cn(
- 'absolute bottom-0 right-0 flex rounded-full border-2',
- selected ? 'border-sidebar-item-active' : 'border-sidebar group-hover:border-sidebar-item-hover',
+ 'absolute bottom-0 right-0 flex rounded-full',
+ compact ? 'border-[1.5px]' : 'border-2',
+ selected
+ ? 'border-sidebar-item-active'
+ : 'border-sidebar group-hover:border-sidebar-item-hover',
)}
>
- <BotAvatar bot={second} size="xs" className="h-6 w-6 text-12" />
+ <BotAvatar
+ bot={second}
+ size="xs"
+ className={compact ? 'h-[18px] w-[18px] text-10' : 'h-6 w-6 text-12'}
+ />
</span>
</span>
);
diff --git a/apps/desktop/src/renderer/features/bots/BotGroupSidebarRow.tsx b/apps/desktop/src/renderer/features/bots/BotGroupSidebarRow.tsx
index 6a9f16af39..45d780eed7 100644
--- a/apps/desktop/src/renderer/features/bots/BotGroupSidebarRow.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotGroupSidebarRow.tsx
@@ -1,8 +1,8 @@
/**
* 统一伙伴列表里的群聊行,和伙伴私聊共同按最新消息排序。
*
- * 群行与伙伴行同一套 IM 行几何(见 __tests__/botsSidebarSpacing.test.ts):左侧两位
- * 成员的叠放头像,第一行群名,第二行最近一条消息「作者:内容」。有伙伴正在发言时,
+ * 群行与伙伴行同一套 IM 行几何(见 __tests__/botsSidebarSpacing.test.ts):左侧按人数
+ * 显示组合头像,第一行群名,第二行最近一条消息「作者:内容」。有伙伴正在发言时,
* 第二行临时让位给运行中标记(橙色 sparkles + 发言伙伴的工作状态,DESIGN.md §2
* Thinking Orange 的侧栏运行态),一轮结束就落回最近消息。
*
@@ -22,7 +22,7 @@ import { cn } from '@/lib/utils';
import type { AgentIslandSessionActivity } from '../../../shared/agentIsland';
import type { BotGroupSummary } from '../../../shared/botGroupChat';
import { BotGenerationLabel } from './BotGenerationLabel';
-import { BotGroupDuoAvatar } from './BotGroupAvatars';
+import { BotGroupSidebarAvatar } from './BotGroupAvatars';
import { isBotGroupLaneSession } from './botGroupLane';
import {
botGroupNoticeKey,
@@ -178,6 +178,7 @@ export function BotGroupSidebarRow({
const timestamp = formatBotListTimestamp(
!group.archived && group.speakingBotIds.length > 0 ? now : group.lastMessage?.createdAt ?? group.updatedAt,
now,
+ t,
);
return (
<div className="relative">
@@ -197,7 +198,7 @@ export function BotGroupSidebarRow({
: 'text-[var(--sidebar-nav-text)] hover:bg-sidebar-item-hover',
)}
>
- <BotGroupDuoAvatar members={group.members} selected={selected} />
+ <BotGroupSidebarAvatar members={group.members} selected={selected} />
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
<span className="flex min-w-0 items-center gap-1.5">
<span className="min-w-0 truncate text-14 leading-5" title={group.name}>{group.name}</span>
@@ -207,7 +208,7 @@ export function BotGroupSidebarRow({
</span>
<span
className={cn(
- 'w-10 shrink-0 self-start pt-0.5 text-right text-11 tabular-nums',
+ 'min-w-10 shrink-0 self-start whitespace-nowrap pt-0.5 text-right text-11 tabular-nums',
mutedClass,
)}
>
diff --git a/apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx b/apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx
index 172fca7eae..34837ea9b8 100644
--- a/apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx
+++ b/apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx
@@ -56,26 +56,38 @@ export function CindyDeviceRow({
className="absolute inset-0 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
aria-label={`${bot.name} · ${current.label}`}
/>
- <span className="pointer-events-none relative shrink-0">
+ <span className="pointer-events-none relative flex shrink-0">
<BotAvatar bot={bot} size="md" />
<BotConnectionStatus
online={'deviceId' in bot && bot.connectionKnown === false ? null : current.online}
deviceName={current.label}
/>
</span>
- <div className="pointer-events-none relative grid min-w-0 flex-1 grid-cols-[minmax(0,1fr)_2.5rem] items-center gap-x-2.5 gap-y-0.5">
+ <div className="pointer-events-none relative grid min-w-0 flex-1 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-0.5">
<span className="flex min-w-0 items-center gap-2">
{'pinnedAt' in bot && bot.pinnedAt ? (
<Pin size={11} aria-label={t('bots.list.pinned')} className="shrink-0" />
) : null}
<span
className={cn(
- 'min-w-0 flex-1 truncate text-14 leading-5',
+ 'min-w-0 truncate text-14 leading-5',
current.unread && 'font-medium',
)}
>
{bot.name}
</span>
+ <CindyDevicePicker
+ options={options}
+ current={current}
+ onSelect={onSelect}
+ className={cn(
+ 'pointer-events-auto h-5 min-w-0 shrink px-1 text-11 text-inherit focus-visible:ring-inset',
+ '[--button-face-bg:transparent] [--button-face-border:transparent] [--button-face-outset:0px]',
+ 'enabled:[&:not([aria-disabled=true])]:hover:[--button-face-bg:var(--sidebar-item-hover)] enabled:[&:not([aria-disabled=true])]:active:[--button-face-bg:var(--sidebar-item-hover)]',
+ selected &&
+ 'enabled:[&:not([aria-disabled=true])]:hover:[--button-face-bg:color-mix(in_srgb,currentColor_10%,transparent)] enabled:[&:not([aria-disabled=true])]:active:[--button-face-bg:color-mix(in_srgb,currentColor_16%,transparent)]',
+ )}
+ />
{'needsAttention' in bot && bot.needsAttention ? (
<AlertTriangle
size={13}
@@ -84,19 +96,7 @@ export function CindyDeviceRow({
/>
) : null}
</span>
- <span className={cn('min-h-4 justify-self-end text-11 tabular-nums', mutedClass)}>{timestamp}</span>
- <CindyDevicePicker
- options={options}
- current={current}
- onSelect={onSelect}
- className={cn(
- 'pointer-events-auto col-span-2 -ml-2 justify-self-start text-12 text-inherit focus-visible:ring-inset',
- '[--button-face-bg:transparent] [--button-face-border:transparent] [--button-face-outset:0px]',
- 'enabled:[&:not([aria-disabled=true])]:hover:[--button-face-bg:var(--sidebar-item-hover)] enabled:[&:not([aria-disabled=true])]:active:[--button-face-bg:var(--sidebar-item-hover)]',
- selected &&
- 'enabled:[&:not([aria-disabled=true])]:hover:[--button-face-bg:color-mix(in_srgb,currentColor_10%,transparent)] enabled:[&:not([aria-disabled=true])]:active:[--button-face-bg:color-mix(in_srgb,currentColor_16%,transparent)]',
- )}
- />
+ <span className={cn('min-h-4 min-w-10 justify-self-end whitespace-nowrap text-right text-11 tabular-nums', mutedClass)}>{timestamp}</span>
<span
className={cn('truncate text-12 leading-4', mutedClass, typing && 'italic')}
title={typeof subtitle === 'string' ? subtitle : undefined}
diff --git a/apps/desktop/src/renderer/features/bots/TeammatesSection.tsx b/apps/desktop/src/renderer/features/bots/TeammatesSection.tsx
index 70924e35db..b2b59ec6d3 100644
--- a/apps/desktop/src/renderer/features/bots/TeammatesSection.tsx
+++ b/apps/desktop/src/renderer/features/bots/TeammatesSection.tsx
@@ -45,6 +45,7 @@ import { BotAvatar } from './BotAvatar';
import { BotCreateMenu } from './BotCreateMenu';
import { BotDeleteDialog } from './BotDeleteDialog';
import { BotGroupSidebarRow } from './BotGroupSidebarRow';
+import { BotGroupSidebarAvatar } from './BotGroupAvatars';
import { refreshBotGroups, useBotGroupList } from './botGroupStore';
import { BOT_GROUP_SETTINGS_PARAM } from './botGroupPresentation';
import { chatErrorKey } from './chatError';
@@ -111,26 +112,6 @@ function useAvatarRowCapacity(ref: RefObject<HTMLDivElement | null>, active: boo
return width > 0 ? Math.max(1, Math.floor((width + 8) / AVATAR_SLOT_PX)) : Number.POSITIVE_INFINITY;
}
-/** 群聊在头像行里用两位成员叠放,和单聊头像一眼可分。 */
-function GroupMiniAvatar({ members }: { members: readonly Parameters<typeof BotAvatar>[0]['bot'][] }) {
- const [first, second] = members;
- if (!first || !second) {
- return (
- <span aria-hidden className="flex h-7 w-7 items-center justify-center rounded-full bg-[var(--surface-chip)] text-[var(--sidebar-list-muted)]">
- <Users size={14} strokeWidth={2} />
- </span>
- );
- }
- return (
- <span aria-hidden className="relative block h-7 w-7">
- <BotAvatar bot={first} size="xs" className="absolute left-0 top-0 h-[18px] w-[18px] text-10" />
- <span className="absolute bottom-0 right-0 flex rounded-full border-[1.5px] border-sidebar">
- <BotAvatar bot={second} size="xs" className="h-[18px] w-[18px] text-10" />
- </span>
- </span>
- );
-}
-
/**
* 侧栏第一层的「伙伴」段(2026-10-13 定稿):固定在置顶段上方,与置顶、全部任务并存。
* 点伙伴只切换主区域,左栏不再整栏切换。段名在「展开(行列表)」与「收起成一排头像」
@@ -552,7 +533,7 @@ export function TeammatesSection() {
)}
>
{entry.kind === 'group' ? (
- <GroupMiniAvatar members={entry.group.members} />
+ <BotGroupSidebarAvatar members={entry.group.members} compact />
) : (entry.kind === 'cindy' ? currentCindy?.bot : entry.bot) ? (
<BotAvatar bot={(entry.kind === 'cindy' ? currentCindy?.bot : entry.bot)!} size="sm" />
) : null}
@@ -612,7 +593,7 @@ export function TeammatesSection() {
selected={selected} typing={Boolean(activity || ('deviceId' in bot && bot.online && bot.generation))} subtitle={subtitleText}
timestamp={formatBotListTimestamp(local
? botListTimestampAt({ lastMessageAt: local.lastMessageAt, working: Boolean(activity) }, now)
- : 'activityAt' in bot ? bot.activityAt : 0, now)}
+ : 'activityAt' in bot ? bot.activityAt : 0, now, t)}
onOpen={() => navigate(currentCindy.route)}
onSelect={option => navigate(option.route)}
onContextMenu={local ? event => {
@@ -638,12 +619,14 @@ export function TeammatesSection() {
className={cn('flex w-full min-w-0 items-center gap-2.5 rounded-xl px-2.5 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring', selected ? 'bg-sidebar-item-active text-sidebar-item-active-foreground' : 'text-[var(--sidebar-nav-text)] hover:bg-sidebar-item-hover')}>
<span className="relative shrink-0"><BotAvatar bot={bot} size="md" /><BotConnectionStatus online={bot.connectionKnown === false ? null : bot.online} deviceName={deviceName} homeOffline={isCloudHomeOffline(cloud, bot)} /></span>
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
- <span className="truncate text-14 leading-5">{bot.name}</span>
- <BotConnectionStatus inline online={bot.connectionKnown === false ? null : bot.online} deviceName={deviceName} homeOffline={isCloudHomeOffline(cloud, bot)} className={selected ? 'opacity-70' : 'text-[var(--text-secondary)]'} />
- <span className="truncate text-12 leading-4 text-[var(--sidebar-list-muted)]">{bot.online && bot.generation ? <BotGenerationLabel sessionId={bot.sessionId ?? undefined} {...bot.generation} remote={{ deviceId: bot.deviceId, botId: bot.id }} /> : bot.preview || bot.description || t('bots.list.startChat')}</span>
+ <span className="flex min-w-0 items-baseline gap-2">
+ <span className="min-w-0 truncate text-14 leading-5">{bot.name}</span>
+ <BotConnectionStatus inline online={bot.connectionKnown === false ? null : bot.online} deviceName={deviceName} homeOffline={isCloudHomeOffline(cloud, bot)} className={selected ? 'opacity-70' : 'text-[var(--sidebar-list-muted)]'} />
+ </span>
+ <span className={cn('truncate text-12 leading-4', selected ? 'opacity-70' : 'text-[var(--sidebar-list-muted)]')}>{bot.online && bot.generation ? <BotGenerationLabel sessionId={bot.sessionId ?? undefined} {...bot.generation} remote={{ deviceId: bot.deviceId, botId: bot.id }} /> : bot.preview || bot.description || t('bots.list.startChat')}</span>
</span>
{!selected && isRemoteBotUnread(bot) ? <span aria-label={t('bots.list.unread', { count: 1 })} className="size-[7px] shrink-0 rounded-full bg-[var(--bot-unread-bg)]" /> : null}
- <span className="w-10 shrink-0 self-start pt-0.5 text-right text-11 tabular-nums text-[var(--sidebar-list-muted)]">{formatBotListTimestamp(bot.activityAt, now)}</span>
+ <span className={cn('min-w-10 shrink-0 self-start whitespace-nowrap pt-0.5 text-right text-11 tabular-nums', selected ? 'opacity-70' : 'text-[var(--sidebar-list-muted)]')}>{formatBotListTimestamp(bot.activityAt, now, t)}</span>
</button>
);
}
@@ -666,6 +649,7 @@ export function TeammatesSection() {
const timestamp = formatBotListTimestamp(
botListTimestampAt({ lastMessageAt: bot.lastMessageAt, working: typing }, now),
now,
+ t,
);
// The selected pill is a light/dark gray fill, not an inverse one,
// so muted text on it would sit at a far lower contrast than on
@@ -726,6 +710,7 @@ export function TeammatesSection() {
>
{botRosterLabel(bot, bots)}
</span>
+ {!typing && <BotConnectionStatus inline className={selected ? 'opacity-70' : 'text-[var(--sidebar-list-muted)]'} />}
{/* 权限模式仍不在聊天列表挂警告;这里仅显示 Hermes 风格、
已持久化且需要用户处理的运行失败。 */}
{bot.needsAttention ? (
@@ -736,7 +721,6 @@ export function TeammatesSection() {
/>
) : null}
</span>
- {!typing && <BotConnectionStatus inline className={selected ? 'opacity-70' : 'text-[var(--text-secondary)]'} />}
<span className="flex min-w-0 items-center gap-2">
{/* 未读只强调名字与数字,预览保持次级,避免整行同时争抢注意力。 */}
<span
@@ -755,11 +739,9 @@ export function TeammatesSection() {
</span>
</span>
{/*
- Grok / Hermes 都把消息行当成完整的联系人入口。时间与未读因此
- 有自己的固定右列,不再跟名字和预览抢剩余宽度;无论名字多长、
- 有没有未读,所有数字都落在同一条垂直线上。
+ 时间与未读共用右对齐列;相对时间按文字宽度撑开,避免折行。
*/}
- <span className="flex w-10 shrink-0 self-stretch flex-col items-end justify-between py-0.5">
+ <span className="flex min-w-10 shrink-0 self-stretch flex-col items-end justify-between whitespace-nowrap py-0.5">
<span className={cn('min-h-4 text-11 tabular-nums', mutedClass)}>{timestamp}</span>
<span className="flex min-h-4 items-center justify-end">
{unread > 0 ? (
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/BotConnectionStatus.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/BotConnectionStatus.test.tsx
index 340acf009d..5a013a3f6a 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/BotConnectionStatus.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/BotConnectionStatus.test.tsx
@@ -4,14 +4,18 @@ import { afterEach, expect, it, vi } from 'vitest';
import { BotConnectionStatus } from '../BotConnectionStatus';
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
afterEach(cleanup);
-it('local online stays green; only known remote offline is red; unknown stays neutral', () => {
+it('only known offline shows a status dot; online and unknown stay quiet', () => {
const view = render(<BotConnectionStatus />);
const dot = () => view.container.firstElementChild!;
- expect(dot().className).toContain('--remote-status-ready');
- expect(dot().getAttribute('title')).toBe('bots.remote.online');
+ expect(dot()).toBeNull();
view.rerender(<BotConnectionStatus online={false} />);
expect(dot().className).toContain('--remote-status-failed');
view.rerender(<BotConnectionStatus online={null} />);
- expect(dot().className).toContain('--text-tertiary');
- expect(dot().getAttribute('title')).toBe('bots.remote.unknown');
+ expect(dot()).toBeNull();
+ view.rerender(<BotConnectionStatus inline />);
+ expect(dot()).toBeNull();
+ view.rerender(<BotConnectionStatus inline deviceName="Studio" />);
+ expect(dot().textContent).toBe('Studio');
+ view.rerender(<BotConnectionStatus inline online={false} deviceName="Studio" />);
+ expect(dot().textContent).toBe('bots.remote.offline · Studio');
});
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botListDisplay.test.ts b/apps/desktop/src/renderer/features/bots/__tests__/botListDisplay.test.ts
index 33de88f089..55de2bafdc 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botListDisplay.test.ts
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botListDisplay.test.ts
@@ -10,17 +10,22 @@ import {
describe('Bots list timestamp', () => {
const now = new Date(2026, 7, 17, 14, 5, 0).getTime();
- it('shows the clock for today and the date for anything older', () => {
- expect(formatBotListTimestamp(new Date(2026, 7, 17, 9, 7, 0).getTime(), now)).toBe('09:07');
- expect(formatBotListTimestamp(new Date(2026, 7, 17, 23, 59, 0).getTime(), now)).toBe('23:59');
- expect(formatBotListTimestamp(new Date(2026, 7, 16, 23, 59, 0).getTime(), now)).toBe('8/16');
- expect(formatBotListTimestamp(new Date(2025, 11, 3, 8, 0, 0).getTime(), now)).toBe('12/3');
+ it('shows the same relative units as the task list', () => {
+ expect(formatBotListTimestamp(now, now)).toBe('now');
+ expect(formatBotListTimestamp(now - 5 * 60_000, now)).toBe('5m');
+ expect(formatBotListTimestamp(new Date(2026, 7, 17, 9, 7, 0).getTime(), now)).toBe('4h');
+ expect(formatBotListTimestamp(new Date(2026, 7, 17, 23, 59, 0).getTime(), now)).toBe('now');
+ expect(formatBotListTimestamp(now - 2 * 86_400_000, now)).toBe('2d');
+ expect(formatBotListTimestamp(now - 21 * 86_400_000, now)).toBe('3w');
+ expect(formatBotListTimestamp(new Date(2025, 11, 3, 8, 0, 0).getTime(), now)).toBe('8mo');
});
it('renders nothing when the Bot has no message yet', () => {
expect(formatBotListTimestamp(null, now)).toBe('');
expect(formatBotListTimestamp(undefined, now)).toBe('');
expect(formatBotListTimestamp(0, now)).toBe('');
+ expect(formatBotListTimestamp(Number.NaN, now)).toBe('');
+ expect(formatBotListTimestamp(Number.MAX_VALUE, now)).toBe('');
});
});
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/teammatesSection.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/teammatesSection.test.tsx
index d06d2170fd..1942503375 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/teammatesSection.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/teammatesSection.test.tsx
@@ -189,7 +189,7 @@ describe('one Cindy entry across devices', () => {
expect(screen.queryByRole('combobox', { name: /bots.devicePicker.switchDevice/ })).toBeNull();
expect(screen.queryByTestId('cindy-device-row')).toBeNull();
expect(screen.queryByText('bots.devicePicker.local')).toBeNull();
- expect(screen.getByText('bots.remote.online')).toBeTruthy();
+ expect(screen.queryByText('bots.remote.online')).toBeNull();
fireEvent.click(screen.getByText('Local preview').closest('button')!);
expect(mocks.navigate).toHaveBeenCalledWith('/bots/cindy-default');
@@ -204,7 +204,7 @@ describe('one Cindy entry across devices', () => {
expect(screen.queryByRole('combobox', { name: /bots.devicePicker.switchDevice/ })).toBeNull();
expect(screen.queryByTestId('cindy-device-row')).toBeNull();
expect(screen.queryByText('bots.devicePicker.local')).toBeNull();
- expect(screen.getByText('bots.remote.online')).toBeTruthy();
+ expect(screen.queryByText('bots.remote.online')).toBeNull();
expect(screen.getByText('Local preview')).toBeTruthy();
});
@@ -310,10 +310,10 @@ describe('teammate host labels', () => {
name: 'Cindy', avatar: '🤖', avatarColor: 'violet', description: '', preview: 'Remote preview',
activityAt: 1, sessionId: 'remote-session', online: true }];
const view = await renderSidebar();
- expect(screen.getByText('bots.remote.online')).toBeTruthy();
+ expect(screen.queryByText('bots.remote.online')).toBeNull();
expect(view.container.innerHTML).not.toContain('MBP-M5');
expect(screen.queryByRole('img', { name: /bots.remote.online/ })).toBeNull();
- expect(screen.getByText('bots.remote.online · Mac-Studio')).toBeTruthy();
+ expect(screen.getByText('Mac-Studio')).toBeTruthy();
expect(screen.getByText('Local preview')).toBeTruthy();
const remoteRow = screen.getByText('Remote preview').closest('button')!;
fireEvent.click(remoteRow);
@@ -328,12 +328,12 @@ describe('teammate host labels', () => {
it('keeps local status free of device labels before and after directory updates', async () => {
mocks.profiles = [bot({ id: 'local-bot', name: 'Cindy' })];
const view = await renderSidebar();
- expect(screen.getByText('bots.remote.online')).toBeTruthy();
+ expect(screen.queryByText('bots.remote.online')).toBeNull();
expect(view.container.innerHTML).not.toContain('bots.remote.thisDevice');
expect(view.container.textContent).not.toContain(' · ');
mocks.devices = [{ deviceId: 'local-device', name: 'Renamed Mac', isSelf: true }];
view.rerender(<TeammatesSection />);
- expect(screen.getByText('bots.remote.online')).toBeTruthy();
+ expect(screen.queryByText('bots.remote.online')).toBeNull();
expect(view.container.innerHTML).not.toContain('Renamed Mac');
expect(view.container.textContent).not.toContain(' · ');
});
@@ -347,13 +347,13 @@ describe('teammate host labels', () => {
activityAt: 1, sessionId: 'remote-session', online: true,
}));
const view = await renderSidebar();
- expect(screen.getByText('bots.remote.online · Shared Mac (host-a)')).toBeTruthy();
- expect(screen.getByText('bots.remote.online · Shared Mac (host-b)')).toBeTruthy();
+ expect(screen.getByText('Shared Mac (host-a)')).toBeTruthy();
+ expect(screen.getByText('Shared Mac (host-b)')).toBeTruthy();
expect(view.container.innerHTML).not.toContain('local-device');
mocks.remoteBots = mocks.remoteBots.map((entry) => ({ ...entry, deviceName: entry.deviceId === 'host-a' ? 'Studio' : 'Mini' }));
view.rerender(<TeammatesSection />);
- expect(screen.getByText('bots.remote.online · Studio')).toBeTruthy();
- expect(screen.getByText('bots.remote.online · Mini')).toBeTruthy();
+ expect(screen.getByText('Studio')).toBeTruthy();
+ expect(screen.getByText('Mini')).toBeTruthy();
});
it.each(['Thinking', 'Generating'])('preserves %s while hiding the local host and idle status', async (compactDetail) => {
@@ -371,7 +371,7 @@ describe('teammate host labels', () => {
mocks.islandActivity.clear();
view.rerender(<TeammatesSection />);
expect(screen.queryByText(compactDetail)).toBeNull();
- expect(screen.getByText('bots.remote.online')).toBeTruthy();
+ expect(screen.queryByText('bots.remote.online')).toBeNull();
expect(screen.getByText('Previous reply')).toBeTruthy();
});
@@ -579,8 +579,7 @@ describe('TeammatesSection rows', () => {
});
it('shows the latest message and its time instead of a channel label', async () => {
- const at = new Date();
- at.setHours(9, 7, 0, 0);
+ const at = new Date(Date.now() - 5 * 60_000);
mocks.profiles = [
bot({
id: 'bot-1',
@@ -594,7 +593,7 @@ describe('TeammatesSection rows', () => {
const view = await renderSidebar();
expect(screen.getByText('Two checks are still red on #2829')).toBeTruthy();
- expect(screen.getByText('09:07')).toBeTruthy();
+ expect(screen.getByText(translate('ccAgent.time.relative.minute', { count: 5 }))).toBeTruthy();
expect(view.container.textContent).not.toContain('Local');
expect(screen.queryByText('Delivery steward')).toBeNull();
});
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/teammatesSectionSpacing.test.ts b/apps/desktop/src/renderer/features/bots/__tests__/teammatesSectionSpacing.test.ts
index 2968f3d3d0..fe57e4cf9b 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/teammatesSectionSpacing.test.ts
+++ b/apps/desktop/src/renderer/features/bots/__tests__/teammatesSectionSpacing.test.ts
@@ -12,7 +12,7 @@
* .row-open { flex:1; padding:8px 10px; gap:10px } → px-2.5 py-2 gap-2.5(左右对称)
* .row-l1 { display:flex; align-items:baseline; gap:8px } → gap-2
* .row-l2 { display:flex; align-items:center; gap:8px; margin-top:2px } → gap-2 + 外层 flex-col gap-0.5
- * .row-meta { width:40px; align-items:flex-end } → w-10 items-end
+ * .row-meta { min-width:40px; align-items:flex-end } → min-w-10 items-end
* .row-name { font-size:14px } → text-14
* .row-time { font-size:11px; flex:none } → text-11 shrink-0
* .row-prev { font-size:12.5px } → text-12(仓库字号阶梯里最近的一档)
@@ -86,9 +86,9 @@ describe('伙伴行的间距基线', () => {
);
});
- it('时间与未读共用固定右列,不会被名字或预览推来推去', () => {
+ it('时间与未读共用右列,较长的相对时间不折行', () => {
const start = source.indexOf(
- '<span className="flex w-10 shrink-0 self-stretch flex-col items-end justify-between py-0.5">',
+ '<span className="flex min-w-10 shrink-0 self-stretch flex-col items-end justify-between whitespace-nowrap py-0.5">',
);
const metaColumn = source.slice(start, source.indexOf('</button>', start));
expect(metaColumn).toContain("aria-label={t('bots.list.unread', { count: unread })}");
@@ -145,6 +145,6 @@ describe('群聊与伙伴行同一套几何', () => {
expect(groupRow).toContain('<span className="flex min-w-0 flex-1 flex-col gap-0.5">');
expect(groupRow).toContain('min-w-0 truncate text-14 leading-5');
expect(groupRow).toContain("'min-w-0 flex-1 truncate text-12 leading-4'");
- expect(groupRow).toContain("'w-10 shrink-0 self-start pt-0.5 text-right text-11 tabular-nums'");
+ expect(groupRow).toContain("'min-w-10 shrink-0 self-start whitespace-nowrap pt-0.5 text-right text-11 tabular-nums'");
});
});
diff --git a/apps/desktop/src/renderer/features/bots/botListDisplay.ts b/apps/desktop/src/renderer/features/bots/botListDisplay.ts
index 75da926fa8..01aeff9689 100644
--- a/apps/desktop/src/renderer/features/bots/botListDisplay.ts
+++ b/apps/desktop/src/renderer/features/bots/botListDisplay.ts
@@ -3,6 +3,7 @@
* line, latest message on the second). Kept out of the component so the
* fallback chain and the timestamp format are unit-testable without a DOM.
*/
+import { formatSidebarTime } from '../cc-agent/lib/formatSidebarTime';
/**
* 行上该显示哪一刻。
@@ -28,19 +29,16 @@ export function botListTimestampAt(
: null;
}
-/** Row timestamp: today → `HH:mm`, any older day → `M/D`. */
-export function formatBotListTimestamp(at: number | null | undefined, now: number): string {
+/** Use the same localized relative time as ordinary sidebar tasks. */
+export function formatBotListTimestamp(
+ at: number | null | undefined,
+ now: number,
+ t?: Parameters<typeof formatSidebarTime>[1],
+): string {
if (typeof at !== 'number' || !Number.isFinite(at) || at <= 0) return '';
const stamp = new Date(at);
- const today = new Date(now);
- const sameDay =
- stamp.getFullYear() === today.getFullYear() &&
- stamp.getMonth() === today.getMonth() &&
- stamp.getDate() === today.getDate();
- if (sameDay) {
- return `${String(stamp.getHours()).padStart(2, '0')}:${String(stamp.getMinutes()).padStart(2, '0')}`;
- }
- return `${stamp.getMonth() + 1}/${stamp.getDate()}`;
+ if (Number.isNaN(stamp.getTime())) return '';
+ return formatSidebarTime(stamp.toISOString(), t, new Date(now));
}
/**
diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.md
index 79bb6c2c73..538282bab5 100644
--- a/docs/product-rules/bot-group-chat.md
+++ b/docs/product-rules/bot-group-chat.md
@@ -191,7 +191,9 @@
## 5. 界面
- 群聊行与伙伴私聊混排在侧栏「伙伴」段(置顶上方,与任务列表共用一个侧栏,见
- [cindy-bots-runtime.md](cindy-bots-runtime.md#导航未读与系统角标));段头加号提供新建伙伴与新建群聊。群行显示两位成员的叠放头像、群名与最近一条消息,
+ [cindy-bots-runtime.md](cindy-bots-runtime.md#导航未读与系统角标));段头加号提供新建伙伴与新建群聊。群行显示成员组合头像、群名与最近一条消息:
+ 两人斜向叠放、三人错位重叠、四人及以上显示前四人的错位叠放,沿用与侧栏背景同色的描边区分前后层次。
+ 展开列表与收起头像行使用相同规则,头像区域和行高不随人数增加。
有伙伴正在发言时显示运行中标记。未读角标是真实条数:宿主随摘要给出最近(至多 99 条)别人发来的消息时间
(`incomingMessageTimes`),与本机读位比较;旧宿主没有这份列表时只显示 1。伙伴发的安排卡与回复同样算来信:
本机群的 `lastReplyAt` 取两者里最新的一条,首次种读位时不会把最新的安排卡留成未读。