🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(discover): restore revalidateOnFocus: false on the provider market reads (#20788)
Arvin Xuf83a4fb095de
diff --git a/src/store/discover/slices/provider/action.test.ts b/src/store/discover/slices/provider/action.test.tsindex ec0ee6cb73d..32e421a19a1 100644--- a/src/store/discover/slices/provider/action.test.ts+++ b/src/store/discover/slices/provider/action.test.ts@@ -60,13 +60,28 @@ const syncCalls = async (name: 'providerDetail' | 'providerIdentifiers' | 'provi([key]) => Array.isArray(key) && key[0] === 'replica:sync' && key[1] === name,).map(([key, fetcher, config]) => ({- config: config as { onSuccess?: (data: unknown) => void },+ config: config as { onSuccess?: (data: unknown) => void; revalidateOnFocus?: boolean },fetcher: fetcher as () => Promise<any>,key: key as unknown[],}));};describe('ProviderSlice (replica)', () => {+ it('does not revalidate any provider read on window focus', async () => {+ renderHook(() => {+ const state = useStore.getState();+ state.useFetchProviderList();+ state.useFetchProviderDetail({ identifier: 'openai' });+ state.useFetchProviderIdentifiers();+ });++ for (const name of ['providerList', 'providerDetail', 'providerIdentifiers'] as const) {+ const calls = await syncCalls(name);+ expect(calls.length).toBeGreaterThan(0);+ for (const call of calls) expect(call.config.revalidateOnFocus).toBe(false);+ }+ });+describe('useFetchProviderList', () => {it('requests the list with normalized page / pageSize and the locale', async () => {const { discoverService } = await import('@/services/discover');diff --git a/src/store/discover/slices/provider/action.ts b/src/store/discover/slices/provider/action.tsindex 992fa490070..c574bc47320 100644--- a/src/store/discover/slices/provider/action.ts+++ b/src/store/discover/slices/provider/action.ts@@ -105,7 +105,7 @@ export class ProviderActionImpl {pageSize: params.pageSize ? Number(params.pageSize) : 21,};const queryKey = providerListQueryKey(normalized);- const sync = this.#list.useSync(normalized, { enabled });+ const sync = this.#list.useSync(normalized, { enabled, revalidateOnFocus: false });return this.#toSyncResult(sync, queryKey, !!this.#get().providerListMap[queryKey], enabled);};@@ -125,7 +125,7 @@ export class ProviderActionImpl {withReadme: params.withReadme,};const queryKey = providerDetailQueryKey(normalized);- const sync = this.#detail.useSync(normalized, { enabled });+ const sync = this.#detail.useSync(normalized, { enabled, revalidateOnFocus: false });return this.#toSyncResult(sync,queryKey,@@ -139,7 +139,7 @@ export class ProviderActionImpl {const { enabled = true } = options;const params: ProviderIdentifiersParams = {};const queryKey = providerIdentifiersQueryKey(params);- const sync = this.#identifiers.useSync(params, { enabled });+ const sync = this.#identifiers.useSync(params, { enabled, revalidateOnFocus: false });return this.#toSyncResult(sync,queryKey,