Skip to content

chore: fix agent creation bug #40251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged

chore: fix agent creation bug #40251

merged 1 commit into from
Apr 15, 2025

Conversation

jsartisan
Copy link
Contributor

@jsartisan jsartisan commented Apr 15, 2025

/ok-to-test tags="@tag.Templates"

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.

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/14465699770
Commit: 7050a8b
Cypress dashboard.
Tags: @tag.Templates
Spec:


Tue, 15 Apr 2025 09:31:34 UTC

Copy link
Contributor

coderabbitai bot commented Apr 15, 2025

Walkthrough

This change refactors the template selectors in the codebase. The getTemplatesSelector is simplified from a memoized selector to a direct function. A new selector, getTemplatesByFlagSelector, is introduced to filter templates based on the isAiAgentFlowEnabled flag, specifically excluding templates titled "AI Agent" when the flag is enabled. Several other selectors are updated to use this new filtering logic, ensuring consistent template selection according to the AI agent flow flag.

Changes

File(s) Change Summary
app/client/src/selectors/templatesSelectors.tsx - Refactored getTemplatesSelector to a direct function.
- Added getTemplatesByFlagSelector with filtering logic.
- Updated getFilteredTemplateList, templatesDatasourceFiltersSelector, and getFilterListSelector to use the new selector.

Sequence Diagram(s)

sequenceDiagram
    participant UI
    participant Selectors
    participant State

    UI->>Selectors: Call getFilteredTemplateList (or related selector)
    Selectors->>Selectors: Use getTemplatesByFlagSelector
    Selectors->>State: Access state.ui.templates.templates
    Selectors->>State: Access isAiAgentFlowEnabled flag
    Selectors->>Selectors: Filter templates based on flag logic
    Selectors-->>UI: Return filtered templates
Loading

Possibly related PRs

  • chore: Enable templates for agents #40214: Both PRs modify the selector logic in templatesSelectors.tsx to filter templates based on the AI agent flow flag, including filtering out templates titled "AI Agent" when the flag is enabled, indicating a direct relation in how templates are selected and filtered.

Suggested labels

skip-changelog, ok-to-test

Suggested reviewers

  • hetunandu

Poem

In the land of selectors, a change takes flight,
Filtering templates by flag, making things right.
"AI Agent" steps aside when the flow is enabled,
Logic refactored, complexity unraveled.
With a new selector, the code feels light—
A template tale, both clear and bright!
✨🦾

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Apr 15, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/client/src/selectors/templatesSelectors.tsx (1)

31-32: Changed selector from memoized to direct function.

This change converts getTemplatesSelector from a memoized selector to a direct function. While this simplifies the code, be aware that removing memoization could potentially impact performance if this selector is called frequently with the same state.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc516f3 and 7050a8b.

📒 Files selected for processing (1)
  • app/client/src/selectors/templatesSelectors.tsx (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/client/src/selectors/templatesSelectors.tsx (1)
app/client/src/ce/reducers/index.tsx (1)
  • AppState (98-191)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (4)
app/client/src/selectors/templatesSelectors.tsx (4)

34-56: Good implementation of flag-based template filtering.

The new getTemplatesByFlagSelector properly implements filtering logic based on the isAiAgentFlowEnabled flag. The code:

  1. Uses createSelector for memoization
  2. Shows only templates with "Agent" use case when the flag is enabled
  3. Always filters out templates titled "AI Agent"

The comments clearly explain the filtering logic and include a TODO for future work.


130-130: Updated to use flag-based filtering.

The getFilteredTemplateList now correctly uses the new getTemplatesByFlagSelector instead of the raw templates list, ensuring consistent application of the AI agent flow filtering logic.


194-194: Updated to use flag-based filtering.

The templatesDatasourceFiltersSelector now correctly uses the new getTemplatesByFlagSelector, ensuring datasource filters are derived from the properly filtered templates list.


230-230: Updated to use flag-based filtering.

The getFilterListSelector now correctly uses the new getTemplatesByFlagSelector, ensuring filter lists are derived from the properly filtered templates list.

@jsartisan jsartisan requested a review from hetunandu April 15, 2025 09:02
@jsartisan jsartisan added the ok-to-test Required label for CI label Apr 15, 2025
@jsartisan jsartisan merged commit 76e1e48 into release Apr 15, 2025
49 checks passed
@jsartisan jsartisan deleted the chore/fix-template-bug branch April 15, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants