Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(chat): retain reply files during token recovery
ylliuuu668af10eb2470e
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex 493b2fa798..bc60fc8b41 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -617,6 +617,43 @@ describe('Chat Server result delivery and refresh', () => {expect(deps.dispatch).toHaveBeenCalledOnce();});+ it.each(['members', 'heartbeat'].flatMap(boundary =>+ ['TOKEN_EXPIRED', 'INVALID_TOKEN', 'AUTH_REQUIRED', 'INVALID_CHAT_RESPONSE'].map(code => [boundary, code])))+ ('retains reply files through refreshable 401 at %s (%s)', async (boundary, code) => {+ let denied = false;+ fixture.refresh.mockResolvedValue(false);+ fixture.handle.mockImplementation((route, _method, body) => {+ if (route === '/executions/claim') {+ const next = claimed ? null : { ...execution, requester_id: selfId, access_mode: 'owner' };+ claimed = true; return { body: { execution: next } };+ }+ if (denied && (boundary === 'members' ? route.endsWith('/members') : body?.action === 'heartbeat'))+ return code === 'INVALID_CHAT_RESPONSE' ? { status: 401, rawBody: '<html>unavailable</html>' }+ : { status: 401, body: { error: { code } } };+ if (route.endsWith('/members')) return { body: [+ { id: botId, kind: 'bot', ownerActorId: selfId, state: 'joined', accessRevision: 1, guestAccess: 'tools' },+ { id: selfId, kind: 'human', ownerActorId: selfId, state: 'joined' },+ ] };+ return response(route);+ });+ replyFiles.prepare.mockResolvedValue({ text: 'Report', attachments: [{ id: 'pdf', name: 'report.pdf' }] });+ await start();+ denied = true;+ await service.settleLaneTurn({ ...terminal, resultText: '[Report](./report.pdf)' });+ expect(fixture.upload).not.toHaveBeenCalled();+ expect(deliveries()).toHaveLength(0);+ await vi.advanceTimersByTimeAsync(58_000);+ expect(fixture.upload).not.toHaveBeenCalled();+ denied = false;+ await vi.advanceTimersByTimeAsync(2_000);+ expect(fixture.upload).toHaveBeenCalledOnce();+ expect(deliveries()).toHaveLength(1);+ expect(replyFiles.prepare).toHaveBeenCalledOnce();+ expect(deps.dispatch).toHaveBeenCalledOnce();+ await vi.advanceTimersByTimeAsync(30_000);+ expect(deliveries()).toHaveLength(1);+ });+async function startFileReply() {const original = fixture.handle.getMockImplementation()!;fixture.handle.mockImplementation((route, method, body) => {diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex 68310fb83a..2aef878f7a 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -1426,7 +1426,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceDthrow new GroupToolAuthorizationError();await updateExecution(run, 'heartbeat');} catch (error) {- if (error instanceof ChatResponseError && [401, 403, 404, 409, 410].includes(error.status))+ if (error instanceof ChatResponseError && !recoverableAuth(error) && [401, 403, 404, 409, 410].includes(error.status))throw new GroupToolAuthorizationError();throw error;}