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): 将群聊第一位成员头像完整显示在最前层

Dash0c0ccd1f6688
diff --git a/apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx b/apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx
index f83eea49d2..204642daf8 100644
--- a/apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx
@@ -38,7 +38,8 @@ export function BotGroupSidebarAvatar({
}
if (!second) return <BotAvatar bot={first} size={compact ? 'sm' : 'md'} />;
if (members.length >= 3) {
- const visible = members.slice(0, 5);
+ // 先取群里的前五位,再从后向前绘制:第一位最后绘制,完整露在最前层。
+ const visible = members.slice(0, 5).reverse();
// 以 40px 头像区为基准:3/4/5 人分别用 24/22/20px,收起时同比缩放。
const diameter = visible.length === 3 ? 60 : visible.length === 4 ? 55 : 50;
const radius = (100 - diameter) / 2;
@@ -73,7 +74,7 @@ export function BotGroupSidebarAvatar({
return (
<span aria-hidden className={cn('relative flex shrink-0', frameClass)}>
<BotAvatar
- bot={first}
+ bot={second}
size="xs"
className={cn(
'absolute',
@@ -90,7 +91,7 @@ export function BotGroupSidebarAvatar({
)}
>
<BotAvatar
- bot={second}
+ bot={first}
size="xs"
className={compact ? 'h-[18px] w-[18px] text-10' : 'h-6 w-6 text-12'}
/>
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupAvatars.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupAvatars.test.tsx
index 71f14a2ead..bc14eb9a6a 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupAvatars.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupAvatars.test.tsx
@@ -10,6 +10,15 @@ const members = ['Zulu', 'Alpha', 'Mike', 'Quebec', 'Bravo', 'Echo', 'Charlie',
(name) => ({ botId: name, name, avatar: '', avatarColor: 'violet' }),
);
+// Positioned siblings paint back to front in DOM order. Read the visible stack
+// from the complete foreground avatar backwards, not left to right in the DOM.
+function frontToBackInitials(container: HTMLElement) {
+ return Array.from(container.firstElementChild!.children)
+ .reverse()
+ .map((avatar) => avatar.textContent)
+ .join('');
+}
+
describe.each([false, true])('sidebar avatars (compact=%s)', (compact) => {
it.each([
[2, 'ZA'],
@@ -17,11 +26,11 @@ describe.each([false, true])('sidebar avatars (compact=%s)', (compact) => {
[4, 'ZAMQ'],
[5, 'ZAMQB'],
[8, 'ZAMQB'],
- ] as const)('shows the first members in group order for %i members', (count, initials) => {
+ ] as const)('stacks the first members front to back for %i members', (count, initials) => {
const { container } = render(
<BotGroupSidebarAvatar members={members.slice(0, count)} compact={compact} />,
);
- expect(container.textContent).toBe(initials);
+ expect(frontToBackInitials(container)).toBe(initials);
});
it('follows a changed group order without retaining the old visible members', () => {
@@ -29,6 +38,6 @@ describe.each([false, true])('sidebar avatars (compact=%s)', (compact) => {
<BotGroupSidebarAvatar members={members} compact={compact} />,
);
rerender(<BotGroupSidebarAvatar members={[...members].reverse()} compact={compact} />);
- expect(container.textContent).toBe('DCEBQ');
+ expect(frontToBackInitials(container)).toBe('DCEBQ');
});
});
diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.md
index 95c37c949b..a01cf5c317 100644
--- a/docs/product-rules/bot-group-chat.md
+++ b/docs/product-rules/bot-group-chat.md
@@ -192,7 +192,8 @@
- 群聊行与伙伴私聊混排在侧栏「伙伴」段(置顶上方,与任务列表共用一个侧栏,见
[cindy-bots-runtime.md](cindy-bots-runtime.md#导航未读与系统角标));段头加号提供新建伙伴与新建群聊。群行显示成员组合头像、群名与最近一条消息:
- 两人斜向叠放;三人及以上围绕同一圆心等角度重叠,按群成员顺序取前五人,从左上方开始顺时针排列,整体呈圆形聚拢。
+ 两人斜向叠放;三人及以上围绕同一圆心等角度重叠,按群成员顺序取前五人,整体呈圆形聚拢。
+ 叠放顺序以最前层为第一位:第一位成员完整显示,后续成员依次向后叠放;双人同样遵循此顺序。
头像随展示人数适度缩小,沿用与侧栏背景同色的描边区分前后层次。
展开列表与收起头像行使用相同规则,头像区域和行高不随人数增加。
有伙伴正在发言时显示运行中标记。未读角标是真实条数:宿主随摘要给出最近(至多 99 条)别人发来的消息时间