chore: fix agent creation bug (#40251)

/ok-to-test tags="@tag.Templates"
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added filtering of templates based on the AI agent flow setting,
showing only relevant templates when enabled.

- **Refactor**
- Improved consistency in template filtering across the app by updating
related selectors.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/14465699770>
> Commit: 7050a8bfff005c645f72b007415bc331140374c0
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14465699770&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Templates`
> Spec:
> <hr>Tue, 15 Apr 2025 09:31:34 UTC
<!-- end of auto-generated comment: Cypress test results  -->
This commit is contained in:
Pawan Kumar 2025-04-15 15:03:17 +05:30 committed by GitHub
parent bd28cbd28e
commit 76e1e48a3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,7 +28,10 @@ const fuzzySearchOptions = {
const AGENT_TEMPLATES_USE_CASE = "Agent";
const AGENT_TEMPLATES_TITLE = "AI Agent";
export const getTemplatesSelector = createSelector(
export const getTemplatesSelector = (state: AppState) =>
state.ui.templates.templates;
export const getTemplatesByFlagSelector = createSelector(
(state: AppState) => state.ui.templates.templates,
getIsAiAgentFlowEnabled,
(templates, isAiAgentFlowEnabled) => {
@ -124,7 +127,7 @@ export const getBuildingBlockExplorerCards = createSelector(
);
export const getFilteredTemplateList = createSelector(
getTemplatesSelector,
getTemplatesByFlagSelector,
getTemplateFilterSelector,
getTemplateFiltersLength,
(templates, templatesFilters, numberOfFiltersApplied) => {
@ -188,7 +191,7 @@ export const getSearchedTemplateList = createSelector(
// Get the list of datasources which are used by templates
export const templatesDatasourceFiltersSelector = createSelector(
getTemplatesSelector,
getTemplatesByFlagSelector,
getDefaultPlugins,
(templates, plugins) => {
const datasourceFilters: Filter[] = [];
@ -224,7 +227,7 @@ export const allTemplatesFiltersSelector = (state: AppState) =>
// Get all filters which is associated with atleast one template
// If no template is associated with a filter, then the filter shouldn't be in the filter list
export const getFilterListSelector = createSelector(
getTemplatesSelector,
getTemplatesByFlagSelector,
allTemplatesFiltersSelector,
(templates, allTemplateFilters) => {
const FUNCTIONS_FILTER = "functions";