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): 贴回来源读取复用单条消息的可见性判定

Dashb7e0c40cd782
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
index c81fc39fc3..976817baf8 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts
@@ -1501,6 +1501,7 @@ describe('Chat Server result delivery and refresh', () => {
['a server error', { status: 503, body: { error: { code: 'UNAVAILABLE' } } }, 'loading'],
['a timeout-like failure', null, 'loading'],
['forbidden', { status: 403, body: { error: { code: 'FORBIDDEN' } } }, 'unavailable'],
+ ['gone', { status: 410, body: { error: { code: 'GONE' } } }, 'unavailable'],
] as const)('never shows the card text when reading the reply hits %s', async (_label, reply, status) => {
const outside = '70000000-0000-4000-8000-00000000000b';
const share = msg('90000000-0000-4000-8000-00000000000b', 9, aliceId, { content: shareCard(outside) });
diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.ts
index 2f9a9aae37..42528aec2e 100644
--- a/apps/desktop/src/main/maker-ipc/chatServer.ts
+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts
@@ -312,11 +312,8 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD
const media = createChatMedia(api, current, deps.log, { allowLoopback: !app.isPackaged && process.env.XDT_ISOLATED === '1' && config.baseUrl === 'http://127.0.0.1:3018' });
const threads = createThreadProjection<Message>({
threadPage: (roomId, rootId, limit, before) => api<Message[]>(`/conversations/${roomId}/messages?threadRootId=${rootId}&limit=${limit}${before ? `&before=${before}` : ''}`),
- // Not found and forbidden both mean this reader may not see the reply now.
- message: (roomId, messageId) => api<Message>(`/conversations/${roomId}/messages/${messageId}`).catch(error => {
- if (error instanceof ChatResponseError && (error.status === 404 || error.status === 403)) return null;
- throw error;
- }),
+ // The same visibility rule as every other single-message read.
+ message: async (roomId, messageId) => await readMessage(roomId, messageId) ?? null,
filled: roomId => changed(roomId),
});
let upgrade: Promise<Map<string, string>> | undefined;