Skip to content

fix: Improve chat message button handling#26249

Merged
dlavrenuek merged 8 commits intomasterfrom
fix/node-4374
Feb 26, 2026
Merged

fix: Improve chat message button handling#26249
dlavrenuek merged 8 commits intomasterfrom
fix/node-4374

Conversation

@dlavrenuek
Copy link
Contributor

Summary

Improves chat action button rendering

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/NODE-4374

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)

cubic-dev-ai[bot]

This comment was marked as off-topic.

@codecov
Copy link

codecov bot commented Feb 25, 2026

Bundle Report

Changes will increase total bundle size by 4.46kB (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
editor-ui-esm 42.44MB 4.46kB (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: editor-ui-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/worker-*.js 2.91MB 2.92MB 21725.55% ⚠️
assets/worker-*.js -2.91MB 13.37kB -99.54%
assets/index-*.js 691 bytes 1.14MB 0.06%
assets/users.store-*.js 1.29kB 1.05MB 0.12%
assets/index-*.css 38 bytes 770.53kB 0.0%
assets/usePostMessageHandler-*.js -422 bytes 124.15kB -0.34%
assets/useCanvasOperations-*.js 862 bytes 90.47kB 0.96%
assets/ProjectSettings-*.js 61 bytes 71.42kB 0.09%
assets/ProjectSettings-*.css 104 bytes 27.27kB 0.38%
assets/SettingsSecretsProviders.ee-*.js 842 bytes 23.82kB 3.67%
assets/useSecretsProviderConnection.ee-*.js 988 bytes 2.75kB 56.23% ⚠️

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/frontend/@n8n/chat/src/components/MessageWithButtons.vue">

<violation number="1" location="packages/frontend/@n8n/chat/src/components/MessageWithButtons.vue:46">
P2: The new domain filter only allows URLs matching `window.location.origin`, but NODE-4374 requires handling cases where the webhook runs on a different domain. This will hide legitimate approval buttons for embedded chats hosted on another domain. Update the check to validate against the chat webhook origin/allowed instance URL instead of the current window origin.

(According to linked Linear issue NODE-4374.)</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@n8n-assistant n8n-assistant bot added the n8n team Authored by the n8n team label Feb 25, 2026
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

const isSameDomain = (link: string): boolean => {
try {
const url = new URL(link, window.location.href);
return url.origin === window.location.origin;
Copy link
Contributor

@yehorkardash yehorkardash Feb 25, 2026

Choose a reason for hiding this comment

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

Can those urls include n8n webhook urls? Afaik buttons usually can lead to form-waiting or form endpoint.
Those endpoints can be modified by some env variable(don't remember the name) and it will be different from frontend url. Users may use a proxy for webhooks, which can lead to button not rendering even if it's technically their domain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They can. I just figured that this can be different from the web ui url apparently and am looking how we can get this value in the chat components

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

did run some tests locally to confirm that the links are always generated with the configured webhook url, so there is no need to allow the current origin

@blacksmith-sh

This comment has been minimized.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/frontend/@n8n/chat/src/components/MessageWithButtons.vue">

<violation number="1" location="packages/frontend/@n8n/chat/src/components/MessageWithButtons.vue:22">
P1: According to linked Linear issue NODE-4374, buttons must render only for URLs that point to the n8n instance. Including `window.location.origin` in the allowlist means any host site embedding the widget still accepts its own origin, so prompt-injected buttons can point outside the n8n instance. Limit the allowlist to the webhook origin only.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

yehorkardash
yehorkardash previously approved these changes Feb 25, 2026
Copy link
Contributor

@yehorkardash yehorkardash left a comment

Choose a reason for hiding this comment

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

LGTM, just two nitpicks

const chatOptions = useOptions();
const clickedButtonIndex = ref<number | null>(null);

const isValidOrigin = (link: string): boolean => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would maybe make it computed function

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 did check what the chatOptions are and the result is not reactive, so a computed value would also never be updated

<template v-for="(button, index) in buttons" :key="button.text">
<Button
v-if="clickedButtonIndex === null || index === clickedButtonIndex"
v-if="
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have clickedButtonIndex === null || index === clickedButtonIndex as a variable with a clear name, because it's not clear what is it for

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is indeed not optimal. I did extract the check into the new function and renamed it to isButtonVisible. The clickedButtonIndex.value === null || index === clickedButtonIndex.value is still there since a proper description would be "if no buttons clicked or current button is clicked" and converting it to multiple conditions would not make it better, imo

@github-actions
Copy link
Contributor

@dlavrenuek dlavrenuek added this pull request to the merge queue Feb 26, 2026
@github-actions
Copy link
Contributor

Merged via the queue into master with commit 4b9e7e3 Feb 26, 2026
56 of 59 checks passed
@dlavrenuek dlavrenuek deleted the fix/node-4374 branch February 26, 2026 08:22
@n8n-assistant n8n-assistant bot mentioned this pull request Mar 2, 2026
This was referenced Mar 3, 2026
@n8n-assistant
Copy link
Contributor

n8n-assistant bot commented Mar 3, 2026

Got released with n8n@2.11.0

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants