Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 交付文件预检遇到临时文件系统错误时整条重试;任务卡标题与摘要不在 emoji 中间截断
Chrisbf91b802b881
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex 2be98c6687..06eec5a580 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -6,6 +6,16 @@ vi.mock('../chatServerMedia.js', () => ({ createChatMedia: () => ({ upload: fixtvi.mock('../chatServerWorkspaces.js', () => ({ chatServerWorkspaces: () => ({ read: () => null, save: vi.fn() }) }));vi.mock('../chatMigrationReceipts.js', () => ({ chatMigrationReceipts: () => ({ read: () => null, save: vi.fn() }) }));vi.mock('electron', () => ({ app: { get isPackaged() { return fixture.packaged; }, getPath: () => '/isolated' } }));+// The real filesystem, except an `lstat` failure a test injects for a delivery file.+const fsFault = vi.hoisted(() => ({ lstat: null as Error | null }));+vi.mock('node:fs/promises', async (importOriginal) => {+ const actual = await importOriginal<typeof import('node:fs/promises')>();+ const lstat = (async (...args: Parameters<typeof actual.lstat>) => {+ if (fsFault.lstat) throw fsFault.lstat;+ return actual.lstat(...args);+ }) as typeof actual.lstat;+ return { ...actual, default: { ...actual, lstat }, lstat };+});vi.mock('node:fs', () => ({ existsSync: fixture.exists, readFileSync: () => fixture.config || '{"baseUrl":"https://example.com","token":"test"}' }));vi.mock('../botGroupChatService.js', () => ({ readPersistedReplyText: vi.fn() }));vi.mock('../../localDb/client/current.js', () => ({ getDbClient: () => ({ drizzle: {@@ -645,6 +655,23 @@ describe('Chat Server result delivery and refresh', () => {if (posts) expect(sent[0][2].content).toEqual([{ type: 'text', text: 'Done.' }, taskCard]);});+ it('retries the whole message when a delivery file cannot be checked for now, rather than dropping it', async () => {+ fixture.profiles = [{ id: 'local-bot', displayName: 'Bot', avatar: null, status: 'active' }];+ fixture.handle.mockImplementation((route, method) => {+ if (route.endsWith('/snapshot')) return { body: { room: room(roomId), members: [joined(botId, 'bot')], messages: [], cursor: '1' } };+ if (route.endsWith('/messages') && method === 'POST') return { body: { id: '70000000-0000-4000-8000-000000000001' } };+ return response(route);+ });+ const files = await deliveryFiles(1);+ fsFault.lstat = Object.assign(new Error('EBUSY: resource busy or locked, lstat'), { code: 'EBUSY', syscall: 'lstat', errno: -16 });+ try {+ const posted = await service.postCompanionTaskMessage({ groupId: roomId, botId: 'local-bot', clientId: 'bot-delegation-task:task-1:1:result',+ text: 'Done.', card: taskCard, files });+ expect(posted).toMatchObject({ ok: false, retryable: true });+ expect(fixture.handle.mock.calls.some(([route, method]) => route === `/conversations/${roomId}/messages` && method === 'POST')).toBe(false);+ } finally { fsFault.lstat = null; }+ });+it('hands an old local-only group (a UUID too) to the local service, which refuses for good', async () => {const localPost = vi.fn(async () => ({ ok: false as const, errorCode: 'GROUP_CHANNEL_UNAVAILABLE', retryable: false }));// The local history lists this group and nothing upgraded it: it is not a server room.diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex b22fa49123..31942ffce1 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -1609,7 +1609,11 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDconst stat = await fs.lstat(file.absolutePath);if (stat.isFile()) produced.push({ id: file.absolutePath, name: path.basename(file.absolutePath), category: 'file',mimeType: 'application/octet-stream', size: stat.size, path: file.absolutePath, url: null });- } catch { /* a file deleted since the task finished is simply not delivered */ }+ } catch (error) {+ // Gone or unreadable for good (deleted since the task finished): simply not delivered.+ // A transient filesystem failure keeps the whole message for a retry.+ if (!fileRefusedHere(error)) throw error;+ }}// Files go up one at a time so a refused file never holds back the others: a file this// computer cannot send (empty, over the size limit, unreadable) or the server definitelydiff --git a/packages/maker-shared/src/__tests__/botGroupTask.test.ts b/packages/maker-shared/src/__tests__/botGroupTask.test.tsindex bf4398cfae..e09f90cc6b 100644--- a/packages/maker-shared/src/__tests__/botGroupTask.test.ts+++ b/packages/maker-shared/src/__tests__/botGroupTask.test.ts@@ -44,6 +44,15 @@ describe('group task card (bot-group-chat.md §10)', () => {expect(readBotGroupTaskCard(block)).toBeNull();});+ it('clips a title or summary before an emoji rather than through it', () => {+ // 118 characters then an emoji: a cut at 119 UTF-16 units would keep only its high surrogate.+ const title = `${'a'.repeat(118)}😀 and more`;+ const card = buildBotGroupTaskCard({ meta, state: 'waiting', title, summary: `${'b'.repeat(398)}😀 tail` }, en);+ expect(card.data.title).toBe(`${'a'.repeat(118)}…`);+ expect(card.data.summary).toBe(`${'b'.repeat(398)}…`);+ expect(card.fallback).not.toMatch(/[\ud800-\udbff](?![\udc00-\udfff])/);+ });+it('rejects a view whose task anchor is not a delegation request', () => {expect(parseBotGroupTaskCardView({ meta: { ...meta, role: 'interjection' }, state: 'completed', title: 't' })).toBeNull();expect(parseBotGroupTaskCardView(null)).toBeNull();diff --git a/packages/maker-shared/src/botGroupTask.ts b/packages/maker-shared/src/botGroupTask.tsindex 6e1183888e..19e8a3d122 100644--- a/packages/maker-shared/src/botGroupTask.ts+++ b/packages/maker-shared/src/botGroupTask.ts@@ -48,7 +48,12 @@ export interface BotGroupTaskCardLabels {function clip(value: string, max: number): string {const text = value.replace(/\s+/g, ' ').trim();- return text.length > max ? `${text.slice(0, max - 1)}…` : text;+ if (text.length <= max) return text;+ let end = max - 1;+ // Never split a surrogate pair (emoji and other astral characters are two UTF-16 units).+ const high = text.charCodeAt(end - 1);+ if (high >= 0xd800 && high <= 0xdbff) end -= 1;+ return `${text.slice(0, end)}…`;}export function buildBotGroupTaskCard(view: BotGroupTaskCardView, labels: BotGroupTaskCardLabels): BotGroupTaskCard {