Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): preserve rollback marker across auth pushes
DavidShen1af735def813
diff --git a/apps/desktop/src/renderer/__tests__/authContextSessionBoundary.test.tsx b/apps/desktop/src/renderer/__tests__/authContextSessionBoundary.test.tsxindex 8929132ec6..4dd852dd0e 100644--- a/apps/desktop/src/renderer/__tests__/authContextSessionBoundary.test.tsx+++ b/apps/desktop/src/renderer/__tests__/authContextSessionBoundary.test.tsx@@ -342,7 +342,7 @@ describe('AuthContext session cache boundaries', () => {expect(mocks.cancelRemoteOptimisticSendsForDataOwnerBoundary).toHaveBeenCalledTimes(2);});- it('reconciles Main runtime on a rollback push before the auth IPC rejects', async () => {+ it('does not consume the rollback marker on a same-owner push during teardown', async () => {let rejectLogout!: (error: Error) => void;mocks.service.logout.mockReturnValueOnce(new Promise<void>((_resolve, reject) => {@@ -363,12 +363,13 @@ describe('AuthContext session cache boundaries', () => {expect(mocks.cancelRemoteOptimisticSendsForDataOwnerBoundary).toHaveBeenLastCalledWith({finalizeSessions: false,});- expect(mocks.reconcileSessionsAfterDataOwnerRollback).toHaveBeenCalledTimes(1);+ expect(mocks.reconcileSessionsAfterDataOwnerRollback).not.toHaveBeenCalled();await act(async () => {rejectLogout(new Error('logout failed'));await expect(logout).rejects.toThrow('logout failed');});+ expect(mocks.reconcileSessionsAfterDataOwnerRollback).toHaveBeenCalledTimes(1);expect(getDataOwnerGeneration().dataOwnerId).toBe('account-a');});diff --git a/apps/desktop/src/renderer/contexts/AuthContext.tsx b/apps/desktop/src/renderer/contexts/AuthContext.tsxindex b166ce0780..c8f13089b7 100644--- a/apps/desktop/src/renderer/contexts/AuthContext.tsx+++ b/apps/desktop/src/renderer/contexts/AuthContext.tsx@@ -189,7 +189,11 @@ export function AuthProvider({// against Main: an early rejection keeps the runtime, a late one may not.publishDataOwnerGeneration(null, undefined, { finalizeSessions: false });try {- return await operation();+ const result = await operation();+ // A successful boundary owns the marker lifecycle. A same-owner auth+ // push during teardown must not consume a possible rollback marker.+ pendingOwnerProjectionRef.current = false;+ return result;} catch (error) {// Restore the exact main-owned generation. Recomputing it locally would// make every stamped push from the still-active owner look stale after a@@ -237,9 +241,7 @@ export function AuthProvider({&& state.ownerGeneration === activeDataOwnerGenerationRef.current;const ownerChanged =!pendingSignedOutProjection && activeDataOwnerIdRef.current !== state.dataOwnerId;- const ownerRolledBack =- pendingOwnerProjectionRef.current && !pendingSignedOutProjection && !ownerChanged;- pendingOwnerProjectionRef.current = pendingSignedOutProjection;+ if (pendingSignedOutProjection) pendingOwnerProjectionRef.current = true;// A same-owner push can arrive while an auth boundary is still waiting// for IPC. The pre-commit fence temporarily publishes null, so letting// that push use the default finalizer would stop the current owner's@@ -250,8 +252,8 @@ export function AuthProvider({state.ownerGeneration,{ finalizeSessions: ownerChanged },);- if (ownerRolledBack) void reconcileSessionsAfterDataOwnerRollback();if (ownerChanged) {+ pendingOwnerProjectionRef.current = false;sessionsStore.reset();clearWorkersCache();}