🔃 refactor: Clear MCP only on Model Spec Selection without MCP Servers (#10273)
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Waiting to run
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions

This commit is contained in:
Danny Avila 2025-10-27 20:33:51 -04:00 committed by GitHub
parent 0446d0e190
commit 7973cb42ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 43 additions and 7 deletions

View file

@ -431,7 +431,41 @@ describe('useMCPSelect', () => {
});
});
// Values should sync to empty array when ephemeralAgent.mcp is set to []
// Values should remain unchanged since empty mcp array doesn't trigger update
// (due to the condition: ephemeralAgent?.mcp && ephemeralAgent.mcp.length > 0)
expect(result.current.mcpHook.mcpValues).toEqual(['initial-value']);
});
it('should handle ephemeralAgent with clear mcp value', async () => {
// Create a shared wrapper
const wrapper = createWrapper(['server1', 'server2']);
// Create a component that uses both hooks
const TestComponent = () => {
const mcpHook = useMCPSelect({});
const setEphemeralAgent = useSetRecoilState(ephemeralAgentByConvoId(Constants.NEW_CONVO));
return { mcpHook, setEphemeralAgent };
};
const { result } = renderHook(() => TestComponent(), { wrapper });
// Set initial values
act(() => {
result.current.mcpHook.setMCPValues(['server1', 'server2']);
});
await waitFor(() => {
expect(result.current.mcpHook.mcpValues).toEqual(['server1', 'server2']);
});
// Set ephemeralAgent with clear value
act(() => {
result.current.setEphemeralAgent({
mcp: [Constants.mcp_clear as string],
});
});
// mcpValues should be cleared
await waitFor(() => {
expect(result.current.mcpHook.mcpValues).toEqual([]);
});