Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): reject authorization continuation after rewind
zqchris218142466ea1
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botAuthorizationService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botAuthorizationService.test.tsindex a425d7fdc1..7165857788 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/botAuthorizationService.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/botAuthorizationService.test.ts@@ -418,3 +418,24 @@ describe('durable authorization card deduplication', () => {await h.service.dispose();});});++it('retires an OAuth waiter when the card is rewound during completion persistence', async () => {+ const h = harness();+ await h.service.request('s', { kind: 'plugin', id: 'p' });+ await h.click();+ await flush();+ h.deps.save.mockImplementationOnce(async (card) => {+ h.stored.set(card.snapshot.requestId, structuredClone(card));+ // The Host load predicate now excludes the row through rewindAt.+ h.deps.load.mockResolvedValue(null);+ });+ h.complete();+ await flush();+ expect(h.deps.resume).not.toHaveBeenCalled();+ expect(h.listeners.size).toBe(0);+ expect(h.card().snapshot.terminal).not.toBe(true);+ h.complete();+ await flush();+ expect(h.deps.resume).not.toHaveBeenCalled();+ await h.service.dispose();+});diff --git a/apps/desktop/src/main/maker-ipc/botAuthorizationHost.ts b/apps/desktop/src/main/maker-ipc/botAuthorizationHost.tsindex e65fceb211..173e7650ca 100644--- a/apps/desktop/src/main/maker-ipc/botAuthorizationHost.ts+++ b/apps/desktop/src/main/maker-ipc/botAuthorizationHost.ts@@ -309,12 +309,20 @@ export function initializeBotAuthorizationHost(async resume(card) {await assertSession(card.sessionId);const [row] = await getDbClient()- .drizzle.select({ clearedAt: sessions.clearedAt })- .from(sessions)- .where(eq(sessions.id, card.sessionId))+ .drizzle.select({ id: messages.id })+ .from(messages)+ .innerJoin(sessions, eq(sessions.id, messages.sessionId))+ .where(+ and(+ eq(messages.sessionId, card.sessionId),+ eq(messages.clientId, `bot-authorization:${card.snapshot.requestId}`),+ isNull(messages.rewindAt),+ or(isNull(sessions.clearedAt), gt(messages.createdAt, sessions.clearedAt)),+ ),+ ).limit(1);- if (!row || (row.clearedAt !== null && row.clearedAt >= card.createdAt))- throw new Error('Authorization card was cleared');+ if (!row) throw new Error('Authorization card is no longer visible');+ await assertSession(card.sessionId);await resume(card);},onDisposing: () => cancelGrokOAuthLogin(),diff --git a/apps/desktop/src/main/maker-ipc/botAuthorizationService.ts b/apps/desktop/src/main/maker-ipc/botAuthorizationService.tsindex 2b0fdfe1fc..ff15da0713 100644--- a/apps/desktop/src/main/maker-ipc/botAuthorizationService.ts+++ b/apps/desktop/src/main/maker-ipc/botAuthorizationService.ts@@ -459,6 +459,12 @@ export class BotAuthorizationService {entry.card.completionPending = true;await this.save(entry);if (entry.closed || entry.cancelled) return;+ // Rewind can hide the card while its OAuth action or persistence is awaiting.+ if (!(await this.deps.load(entry.card.snapshot.requestId))) {+ this.close(entry);+ return;+ }+ if (entry.closed || entry.cancelled) return;await this.deps.resume(entry.card);if (entry.closed || entry.cancelled) return;entry.card.snapshot = completedSnapshot;