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(chat): mark a reactor who left after the read as no longer in the group

Dash746a8e044ea8
diff --git a/apps/desktop/src/renderer/features/bots/ChatReactionButton.tsx b/apps/desktop/src/renderer/features/bots/ChatReactionButton.tsx
index 834eca79db..d43f1222c6 100644
--- a/apps/desktop/src/renderer/features/bots/ChatReactionButton.tsx
+++ b/apps/desktop/src/renderer/features/bots/ChatReactionButton.tsx
@@ -71,10 +71,12 @@ export function ChatReactionButton({ groupId, messageId, reaction, revision = 0,
// that disagrees with the count (a change still in flight), keeps the honest count instead.
const current = loaded?.summary === summary ? loaded : null;
const showAvatars = wantsAvatars && (!current || current.reactors?.length === reaction.count);
- // Names follow the latest member projection; only actors no longer in it keep the name read with them.
+ // Membership follows the latest projection both ways: a current member takes its current name, and a
+ // named actor missing from it has left since the read. Only unrecorded actors stay unnamed.
const reactors = showAvatars && current?.reactors ? reactorOrder(current.reactors.map(r => {
- const member = members?.find(m => m.actorId === r.actorId);
- return member ? { ...r, name: member.name, formerMember: false } : r;
+ if (!members) return r;
+ const member = members.find(m => m.actorId === r.actorId);
+ return member ? { ...r, name: member.name, formerMember: false } : r.name !== null ? { ...r, formerMember: true } : r;
}), i18n.language) : null;
const countLabel = t(key('reactionCount'), { emoji: reaction.emoji, count: reaction.count });
const label = reactors?.length
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/ChatReactionButton.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/ChatReactionButton.test.tsx
index 777e30251c..f4d6b89388 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/ChatReactionButton.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/ChatReactionButton.test.tsx
@@ -151,6 +151,17 @@ describe('reaction avatars', () => {
expect(images()).toEqual(['https://example.test/cindy-chris.png']);
});
+ it('marks a reactor who left after the read, without another read', async () => {
+ mocks.reactors.mockResolvedValue({ ok: true, reactors: [reactor('z', 'Zoe')] });
+ const view = render(actions([{ emoji: '👍', count: 1, me: false }]));
+ await waitFor(() => expect(badge().getAttribute('aria-label')).toBe('👍 · 1: Zoe'));
+ // Zoe leaves; her reaction stays and the member list no longer has her.
+ view.rerender(<ChatMessageActions shareScope="group:room" groupId="room" members={members.filter(m => m.actorId !== 'z')}
+ onChanged={vi.fn()} message={message([{ emoji: '👍', count: 1, me: false }])} />);
+ expect(badge().getAttribute('aria-label')).toBe('👍 · 1: Zoe (left)');
+ expect(mocks.reactors).toHaveBeenCalledTimes(1);
+ });
+
it('follows member renames without another read', async () => {
mocks.reactors.mockResolvedValue({ ok: true, reactors: [reactor('z', 'Zoe')] });
const view = render(actions([{ emoji: '👍', count: 1, me: false }]));
diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.md
index d7dcf9a4fb..9aaefa0b97 100644
--- a/docs/product-rules/bot-group-chat.md
+++ b/docs/product-rules/bot-group-chat.md
@@ -366,8 +366,8 @@ Desktop 主群与 Thread 的表情回应徽标参考 Telegram:某个表情的
Chat Server 既有的回应者接口直到最后一页(离群成员保留回应,总数可超过群人数上限)并按群成员投影命名;
读取只读,不触发伙伴资料同步等任何写入。加载期间按人数预留头像位,不撑动消息;读取失败或名单与人数暂不一致时
如实显示数字。回应数、自己的状态或实时回应事件(含人数不变、只换了人的情况)变化时重新读取;实时连接断开期间,
-只换人不换数的变化要到重连回放后才更新,无法回放而重置时,所有回应都按已变化重新读取。仍在群内的回应者名字
-始终取最新的群成员资料(改昵称后立即更新),只有已不在群内的成员沿用读取时的名字。点击仍是添加/取消回应。回归见 `ChatReactionButton.test.tsx`
+只换人不换数的变化要到重连回放后才更新,无法回放而重置时,所有回应都按已变化重新读取。回应者是否在群、叫什么,
+始终按最新的群成员资料双向投影:改昵称、离群或重新加入都会立即更新,离群后沿用读取时的名字并标注不在群中。点击仍是添加/取消回应。回归见 `ChatReactionButton.test.tsx`
与 `chatServer.test.ts`;手机端暂不显示回应。
当前本地验收与正式切源边界见 [Chat Server 本地联调](../dev-rules/chat-server-local-test.md)。