Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): ignore duplicate add-account close requests
chenhong7c2160ee45db
diff --git a/apps/mobile/app/add-account.tsx b/apps/mobile/app/add-account.tsxindex 9ef1c3aec4..560ccd18da 100644--- a/apps/mobile/app/add-account.tsx+++ b/apps/mobile/app/add-account.tsx@@ -30,6 +30,7 @@ export default function AddAccountScreen() {<LoginScreenadditionalAccountonClose={() => {+ if (closeStartedRef.current) return;closeStartedRef.current = true;void auth.cancelAddAccount().then(() => router.replace('/devices'),diff --git a/apps/mobile/src/auth/__tests__/browserAuthSession.test.tsx b/apps/mobile/src/auth/__tests__/browserAuthSession.test.tsxindex 81d56addc4..4db37271e5 100644--- a/apps/mobile/src/auth/__tests__/browserAuthSession.test.tsx+++ b/apps/mobile/src/auth/__tests__/browserAuthSession.test.tsx@@ -292,6 +292,29 @@ describe('browser auth session lifecycle (real AuthProvider, mocked native/netwoexpect(native.storage.has(pendingKey)).toBe(false);});+ it('ignores repeated close taps while cancellation is pending, including storage failure', async () => {+ await act(async () => { await auth.beginAddAccount(); });+ await start();+ const pending = native.storage.get(pendingKey);+ const url = callbackUrl();+ await act(async () => { root.render(<AuthProvider><Probe /><AddAccountScreen /></AuthProvider>); });+ native.writeSecure.mockRejectedValue(new Error('fixture storage unavailable'));+ native.deleteSecure.mockRejectedValue(new Error('fixture storage unavailable'));+ const writes = native.writeSecure.mock.calls.length;+ await act(async () => { native.closeAccount!(); native.closeAccount!(); });+ expect(native.replaceRoute).not.toHaveBeenCalled();+ expect(native.writeSecure.mock.calls.length - writes).toBe(1);+ expect(auth.loginState?.step).toBe('error');+ expect(native.storage.get(pendingKey)).toBe(pending);+ await emitLink(url);+ expect(native.exchange).not.toHaveBeenCalled();+ native.writeSecure.mockImplementation(async (key: string, value: string) => { native.storage.set(key, value); });+ native.deleteSecure.mockImplementation(async (key: string) => { native.storage.delete(key); });+ await act(async () => { native.closeAccount!(); });+ expect(native.replaceRoute).toHaveBeenCalledExactlyOnceWith('/devices');+ expect(native.storage.has(pendingKey)).toBe(false);+ });+it('surfaces a failed unmount cancellation without an unhandled rejection', async () => {await act(async () => { await auth.beginAddAccount(); });await start();