The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(auth): only a current snapshot lifts the logout guard
M3gA-Mind2d93ccf380c8
diff --git a/app/src/providers/CoreStateProvider.tsx b/app/src/providers/CoreStateProvider.tsxindex 183f60b30e..b7d2174509 100644--- a/app/src/providers/CoreStateProvider.tsx+++ b/app/src/providers/CoreStateProvider.tsx@@ -315,7 +315,9 @@ export default function CoreStateProvider({ children }: { children: ReactNode })// unmounted refresh doesn't dispatch; the core latches configRecovered, so// the next live poll still surfaces it. Guarded internally against re-fire.maybeSurfaceConfigRecovery(rawSnapshot.configRecovered, t);- if (!snapshot.sessionToken) {+ // Only a current snapshot may lift the logout guard: a poll that started+ // before `clearSession` can answer "no token" from before the logout.+ if (!snapshot.sessionToken && requestId === snapshotRequestIdRef.current) {loggingOutTokenRef.current = null;}// Capture pre-commit identity outside the setState updater so flipdiff --git a/app/src/providers/__tests__/CoreStateProvider.test.tsx b/app/src/providers/__tests__/CoreStateProvider.test.tsxindex 9a95dee2d0..2e7cfd403c 100644--- a/app/src/providers/__tests__/CoreStateProvider.test.tsx+++ b/app/src/providers/__tests__/CoreStateProvider.test.tsx@@ -1288,6 +1288,48 @@ describe('failed logout keeps the user signed out', () => {expect(screen.getByTestId('token').textContent).toBe('none');});+ it('a stale no-token poll that started before the clear does not lift the guard', async () => {+ resetCoreStateStore();+ setActiveUserId(null);+ vi.mocked(coreStateApi.fetchCoreAppSnapshot).mockReset();+ vi.mocked(coreStateApi.fetchCoreAppSnapshot).mockResolvedValue(+ makeSnapshot({ userId: 'u1', sessionToken: tok1 })+ );+ vi.mocked(coreStateApi.listTeams).mockResolvedValue([]);+ vi.mocked(tauriCommands.logout).mockReset();+ vi.mocked(tauriCommands.logout).mockRejectedValue(new Error('auth_logout timed out'));+ let ctx: CoreStateContextValue | undefined;+ render(+ <CoreStateProvider>+ <Consumer captureCtx={c => (ctx = c)} />+ </CoreStateProvider>+ );+ await waitFor(() => expect(screen.getByTestId('token').textContent).toBe(tok1));++ // A poll is in flight when the user logs out; it answers "no token".+ const stalePoll = deferred<Snapshot>();+ vi.mocked(coreStateApi.fetchCoreAppSnapshot).mockReturnValueOnce(stalePoll.promise);+ let polling!: Promise<void>;+ act(() => {+ polling = ctx!.refresh();+ });+ let clearing!: Promise<void>;+ act(() => {+ clearing = ctx!.clearSession().catch(() => undefined);+ });+ await act(async () => {+ stalePoll.resolve(makeSnapshot({ sessionToken: null }));+ await polling;+ await clearing;+ });++ // The core still holds tok1 (the logout failed): it must stay hidden.+ await act(async () => {+ await ctx!.refresh();+ });+ expect(screen.getByTestId('token').textContent).toBe('none');+ });+it('lets a new login with a different token through', async () => {const ctx = await renderSignedIn();vi.mocked(coreStateApi.fetchCoreAppSnapshot).mockResolvedValue(