fix(auth): refresh RPC cache before deep-link session store (#2384)

This commit is contained in:
Aqil Aziz
2026-05-22 16:30:38 +05:30
committed by GitHub
parent e3948a3479
commit 203367cb45
2 changed files with 14 additions and 0 deletions
@@ -33,6 +33,13 @@ const waitForOAuthAuthReadiness = vi.hoisted(() =>
vi.fn().mockResolvedValue({ ready: true as const })
);
const coreRpcCache = vi.hoisted(() => ({
clearCoreRpcUrlCache: vi.fn(),
clearCoreRpcTokenCache: vi.fn(),
}));
vi.mock('../../services/coreRpcClient', () => coreRpcCache);
vi.mock('../oauthAppVersionGate', async importOriginal => {
const actual = await importOriginal<typeof import('../oauthAppVersionGate')>();
return {
@@ -59,6 +66,8 @@ describe('desktopDeepLinkListener', () => {
waitForOAuthAuthReadiness.mockResolvedValue({ ready: true });
vi.mocked(storeSession).mockReset();
vi.mocked(storeSession).mockResolvedValue(undefined);
coreRpcCache.clearCoreRpcUrlCache.mockClear();
coreRpcCache.clearCoreRpcTokenCache.mockClear();
windowControls.show.mockClear();
windowControls.unminimize.mockClear();
windowControls.setFocus.mockClear();
@@ -172,6 +181,8 @@ describe('desktopDeepLinkListener', () => {
await waitForAuthSettled();
expect(storeSession).toHaveBeenCalledWith('abc', {});
expect(coreRpcCache.clearCoreRpcUrlCache).toHaveBeenCalledTimes(1);
expect(coreRpcCache.clearCoreRpcTokenCache).toHaveBeenCalledTimes(1);
expect(getDeepLinkAuthState().isProcessing).toBe(false);
});
+3
View File
@@ -4,6 +4,7 @@ import { getCurrent, onOpenUrl } from '@tauri-apps/plugin-deep-link';
import { patchCoreStateSnapshot } from '../lib/coreState/store';
import { consumeLoginToken } from '../services/api/authApi';
import { clearCoreRpcTokenCache, clearCoreRpcUrlCache } from '../services/coreRpcClient';
import {
beginDeepLinkAuthProcessing,
completeDeepLinkAuthProcessing,
@@ -76,6 +77,8 @@ const focusMainWindow = async () => {
};
const applySessionToken = async (sessionToken: string): Promise<void> => {
clearCoreRpcUrlCache();
clearCoreRpcTokenCache();
await storeSession(sessionToken, {});
patchCoreStateSnapshot({ snapshot: { sessionToken } });
window.dispatchEvent(new CustomEvent(SESSION_TOKEN_UPDATED_EVENT, { detail: { sessionToken } }));