diff --git a/web/app/components/workflow/nodes/llm/components/memory-system/index.tsx b/web/app/components/workflow/nodes/llm/components/memory-system/index.tsx index e7bead9ff8..3ab14758a5 100644 --- a/web/app/components/workflow/nodes/llm/components/memory-system/index.tsx +++ b/web/app/components/workflow/nodes/llm/components/memory-system/index.tsx @@ -6,7 +6,9 @@ import Collapse from '@/app/components/workflow/nodes/_base/components/collapse' import type { Node, } from '@/app/components/workflow/types' +import Divider from '@/app/components/base/divider' import Tooltip from '@/app/components/base/tooltip' +import MemoryCreateButton from './memory-create-button' import MemorySelector from './memory-selector' import LinearMemory from './linear-memory' import type { Memory } from '@/app/components/workflow/types' @@ -54,6 +56,10 @@ const MemorySystem = ({ triggerClassName='w-4 h-4' /> {collapseIcon} + +
e.stopPropagation()}> + +
{ + const [open, setOpen] = useState(false) + const varList = useStore(s => s.conversationVariables) as ConversationVariable[] + const updateChatVarList = useStore(s => s.setConversationVariables) + const { doSyncWorkflowDraft } = useNodesSyncDraft() + const { + invalidateConversationVarValues, + } = useInspectVarsCrud() + + const handleVarChanged = useCallback(() => { + doSyncWorkflowDraft(false, { + onSuccess() { + invalidateConversationVarValues() + }, + }) + }, [doSyncWorkflowDraft, invalidateConversationVarValues]) + + const handleSave = useCallback(async (newChatVar: ConversationVariable) => { + const newList = [newChatVar, ...varList] + updateChatVarList(newList) + handleVarChanged() + setOpen(false) + }, [varList, updateChatVarList, handleVarChanged, setOpen]) + + return ( + <> + + setOpen(v => !v)}> + + + + + + { + setOpen(false) + }} + /> + + + + ) +} + +export default MemoryCreateButton