- Add useMarketplaceAgentsInfiniteQuery and useGetAgentCategoriesQuery to client/src/data-provider/Agents/

- Replace manual pagination in AgentGrid with infinite query pattern
  - Update imports to use local data provider instead of librechat-data-provider
  - Add proper permission handling with PERMISSION_BITS.VIEW/EDIT constants
  - Improve agent access control by adding requiredPermission validation in backend
  - Remove manual cursor/state management in favor of infinite query built-ins
  - Maintain existing search and category filtering functionality
This commit is contained in:
Danny Avila 2025-06-23 11:44:12 -04:00
parent 6ebcfdf3e2
commit 3f6d7ab7c7
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
9 changed files with 143 additions and 128 deletions

View file

@ -12,7 +12,6 @@ import * as q from '../types/queries';
import { QueryKeys } from '../keys';
import * as s from '../schemas';
import * as t from '../types';
import * as a from '../types/assistants';
import * as permissions from '../accessPermissions';
export { hasPermissions } from '../accessPermissions';
@ -451,52 +450,3 @@ export const useGetEffectivePermissionsQuery = (
...config,
});
};
/* Marketplace */
/**
* Get agent categories with counts for marketplace tabs
*/
export const useGetAgentCategoriesQuery = (
config?: UseQueryOptions<t.TMarketplaceCategory[]>,
): QueryObserverResult<t.TMarketplaceCategory[]> => {
return useQuery<t.TMarketplaceCategory[]>(
[QueryKeys.agentCategories],
() => dataService.getAgentCategories(),
{
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
staleTime: 5 * 60 * 1000, // Cache for 5 minutes
...config,
},
);
};
/**
* Unified marketplace agents query with query string controls
*/
export const useGetMarketplaceAgentsQuery = (
params: {
requiredPermission: number;
category?: string;
search?: string;
limit?: number;
cursor?: string;
promoted?: 0 | 1;
},
config?: UseQueryOptions<a.AgentListResponse>,
): QueryObserverResult<a.AgentListResponse> => {
return useQuery<a.AgentListResponse>(
[QueryKeys.marketplaceAgents, params],
() => dataService.getMarketplaceAgents(params),
{
enabled: !!params.requiredPermission,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
refetchOnMount: false,
staleTime: 2 * 60 * 1000, // Cache for 2 minutes
...config,
},
);
};