fix: Fix variable insertion to only trigger on current line

This commit is contained in:
zhsama
2026-01-20 16:45:20 +08:00
parent e5dc56c483
commit 57a8c453b9

View File

@ -500,8 +500,13 @@ const MixedVariableTextInput = ({
if (!onChange)
return
// compute words after the latest '@' and delete them
const valueWithoutTrigger = value.replace(/@[^@\n]*$/, '')
const valueWithoutTrigger = (() => {
const lineStart = value.lastIndexOf('\n') + 1
const triggerIndex = value.lastIndexOf('@')
if (triggerIndex < lineStart)
return value
return value.slice(0, triggerIndex)
})()
const newValue = `{{@${agent.id}.context@}}${valueWithoutTrigger}`
if (toolNodeId && paramKey) {