Skip to content
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

feat(editor): Restrict when a ChatTrigger Node is added automatically #11523

Merged
merged 10 commits into from
Nov 13, 2024

Conversation

CharlieKolb
Copy link
Contributor

@CharlieKolb CharlieKolb commented Nov 4, 2024

Summary

Tighten the restrictions on when we add a ChatTrigger node for AI Agents or similar.

Screen.Recording.2024-11-08.at.09.31.26.mov

Related Linear tickets, Github issues, and Community forum posts

Part 1 of https://linear.app/n8n/issue/ADO-2728/feature-change-auto-add-of-chattrigger

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added n8n team Authored by the n8n team ui Enhancement in /editor-ui or /design-system labels Nov 4, 2024
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@CharlieKolb CharlieKolb marked this pull request as ready for review November 5, 2024 14:02
@CharlieKolb CharlieKolb force-pushed the ADO-2728/feature-change-auto-add-of-chattrigger branch from 85ef434 to 4538520 Compare November 7, 2024 15:35
Copy link
Contributor

@MiloradFilipovic MiloradFilipovic left a comment

Choose a reason for hiding this comment

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

Looks good. Added one comment

const { getByNameAndVersion } = getNodeTypes();

// We want to add a trigger if there are no triggers other than Manual Triggers
const shouldAddChatTrigger = allNodes.every((node) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit worried about the performance of every for large workflows. Can we use some or something similar that would stop as soon as it finds the trigger that is not the manual trigger?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had the same concern, which is why I moved isCompatibleNode up before the chatTrigger logic. 👍 This way this will only be run on adding compatible nodes.

every will also stop as soon as it hits the first false, so as soon as we encounter a trigger other than MANUAL_TRIGGER. (Though I appreciate larger workflows will scale non-triggers more than triggers usually)

getByNameAndVersion ends up calling a computed property, so we should reuse the one call to the backend to get node types anyway if I understand the code correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I add a comment in the code acknowledging this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, thanks for clarification

Copy link
Contributor

@MiloradFilipovic MiloradFilipovic left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for adding tests! 🙌🏻

Copy link
Contributor

✅ All Cypress E2E specs passed

@CharlieKolb CharlieKolb merged commit 93a6f85 into master Nov 13, 2024
35 checks passed
@CharlieKolb CharlieKolb deleted the ADO-2728/feature-change-auto-add-of-chattrigger branch November 13, 2024 10:00
CharlieKolb added a commit that referenced this pull request Nov 13, 2024
@github-actions github-actions bot mentioned this pull request Nov 13, 2024
@janober
Copy link
Member

janober commented Nov 13, 2024

Got released with [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team Released ui Enhancement in /editor-ui or /design-system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants