Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat(question-classifier): add instanceId to class-item editor (#22002)

Minamiyamaa4bdeba60df4
diff --git a/web/app/components/workflow/nodes/question-classifier/components/class-item.tsx b/web/app/components/workflow/nodes/question-classifier/components/class-item.tsx
index 60650373229..be4a6cb9018 100644
--- a/web/app/components/workflow/nodes/question-classifier/components/class-item.tsx
+++ b/web/app/components/workflow/nodes/question-classifier/components/class-item.tsx
@@ -1,11 +1,12 @@
'use client'
import type { FC } from 'react'
-import React, { useCallback } from 'react'
+import React, { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import type { Topic } from '../types'
import Editor from '@/app/components/workflow/nodes/_base/components/prompt/editor'
import useAvailableVarList from '@/app/components/workflow/nodes/_base/hooks/use-available-var-list'
import type { ValueSelector, Var } from '@/app/components/workflow/types'
+import { uniqueId } from 'lodash-es'
const i18nPrefix = 'workflow.nodes.questionClassifiers'
@@ -29,6 +30,11 @@ const ClassItem: FC<Props> = ({
filterVar,
}) => {
const { t } = useTranslation()
+ const [instanceId, setInstanceId] = useState(uniqueId())
+
+ useEffect(() => {
+ setInstanceId(`${nodeId}-${uniqueId()}`)
+ }, [nodeId])
const handleNameChange = useCallback((value: string) => {
onChange({ ...payload, name: value })
@@ -52,6 +58,7 @@ const ClassItem: FC<Props> = ({
nodesOutputVars={availableVars}
availableNodes={availableNodesWithParent}
readOnly={readonly} // ?
+ instanceId={instanceId}
justVar // ?
isSupportFileVar // ?
/>