fix(web): workflow chat variables init
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @Author: ZhaoYing
|
* @Author: ZhaoYing
|
||||||
* @Date: 2026-02-06 21:10:56
|
* @Date: 2026-02-06 21:10:56
|
||||||
* @Last Modified by: ZhaoYing
|
* @Last Modified by: ZhaoYing
|
||||||
* @Last Modified time: 2026-03-20 11:25:51
|
* @Last Modified time: 2026-03-25 13:57:40
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Workflow Chat Component
|
* Workflow Chat Component
|
||||||
@@ -45,8 +45,10 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { message: messageApi } = App.useApp()
|
const { message: messageApi } = App.useApp()
|
||||||
const toolbarRef = useRef<ChatToolbarRef>(null)
|
const toolbarRef = useRef<ChatToolbarRef>(null)
|
||||||
|
const [toolbarReady, setToolbarReady] = useState(false)
|
||||||
const toolbarCallbackRef = useCallback((node: ChatToolbarRef | null) => {
|
const toolbarCallbackRef = useCallback((node: ChatToolbarRef | null) => {
|
||||||
(toolbarRef as React.MutableRefObject<ChatToolbarRef | null>).current = node
|
(toolbarRef as React.MutableRefObject<ChatToolbarRef | null>).current = node
|
||||||
|
setToolbarReady(!!node)
|
||||||
}, [])
|
}, [])
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
@@ -70,10 +72,10 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
|||||||
}, [open, data?.features])
|
}, [open, data?.features])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open && graphRef.current && toolbarRef.current) {
|
if (open && toolbarReady) {
|
||||||
getVariables()
|
getVariables()
|
||||||
}
|
}
|
||||||
}, [open])
|
}, [open, toolbarReady])
|
||||||
/**
|
/**
|
||||||
* Extracts variables from the workflow's start node and merges with previous values
|
* Extracts variables from the workflow's start node and merges with previous values
|
||||||
*/
|
*/
|
||||||
@@ -103,6 +105,7 @@ const Chat = forwardRef<ChatRef, { appId: string; graphRef: GraphRef; data: Work
|
|||||||
*/
|
*/
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
|
setToolbarReady(false)
|
||||||
setChatList([])
|
setChatList([])
|
||||||
setVariables([])
|
setVariables([])
|
||||||
setConversationId(null)
|
setConversationId(null)
|
||||||
|
|||||||
Reference in New Issue
Block a user