Feat: Display the input parameters of begin in the output result table #3355 (#3534)

### What problem does this PR solve?

Feat: Display the input parameters of begin in the output result table
#3355

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu 2024-11-20 19:16:28 +08:00 committed by Yingfeng Zhang
parent 362db857d0
commit 9b9afa9d6e
2 changed files with 12 additions and 5 deletions

View File

@ -3,7 +3,7 @@ import get from 'lodash/get';
import React, { MouseEventHandler, useCallback, useMemo } from 'react'; import React, { MouseEventHandler, useCallback, useMemo } from 'react';
import JsonView from 'react18-json-view'; import JsonView from 'react18-json-view';
import 'react18-json-view/src/style.css'; import 'react18-json-view/src/style.css';
import { useReplaceIdWithText } from '../../hooks'; import { useGetComponentLabelByValue, useReplaceIdWithText } from '../../hooks';
import { import {
Popover, Popover,
@ -39,11 +39,13 @@ export function NextNodePopover({ children, nodeId, name }: IProps) {
[], [],
); );
const output = get(component, ['obj', 'params', 'output'], {}); const output = get(component, ['obj', 'params', 'output'], {});
const { replacedOutput, getNameById } = useReplaceIdWithText(output); const { replacedOutput } = useReplaceIdWithText(output);
const stopPropagation: MouseEventHandler = useCallback((e) => { const stopPropagation: MouseEventHandler = useCallback((e) => {
e.stopPropagation(); e.stopPropagation();
}, []); }, []);
const getLabel = useGetComponentLabelByValue(nodeId);
return ( return (
<Popover> <Popover>
<PopoverTrigger onClick={stopPropagation} asChild> <PopoverTrigger onClick={stopPropagation} asChild>
@ -73,7 +75,7 @@ export function NextNodePopover({ children, nodeId, name }: IProps) {
<TableBody> <TableBody>
{inputs.map((x, idx) => ( {inputs.map((x, idx) => (
<TableRow key={idx}> <TableRow key={idx}>
<TableCell>{getNameById(x.component_id)}</TableCell> <TableCell>{getLabel(x.component_id)}</TableCell>
<TableCell className="truncate">{x.content}</TableCell> <TableCell className="truncate">{x.content}</TableCell>
</TableRow> </TableRow>
))} ))}

View File

@ -55,6 +55,7 @@ export const useSendNextMessage = () => {
} = useSelectNextMessages(); } = useSelectNextMessages();
const { id: flowId } = useParams(); const { id: flowId } = useParams();
const { handleInputChange, value, setValue } = useHandleMessageInputChange(); const { handleInputChange, value, setValue } = useHandleMessageInputChange();
const { refetch } = useFetchFlow();
const { send, answer, done } = useSendMessageWithSse(api.runCanvas); const { send, answer, done } = useSendMessageWithSse(api.runCanvas);
@ -75,9 +76,11 @@ export const useSendNextMessage = () => {
// cancel loading // cancel loading
setValue(message.content); setValue(message.content);
removeLatestMessage(); removeLatestMessage();
} else {
refetch(); // pull the message list after sending the message successfully
} }
}, },
[flowId, removeLatestMessage, setValue, send], [flowId, send, setValue, removeLatestMessage, refetch],
); );
const handleSendMessage = useCallback( const handleSendMessage = useCallback(
@ -112,8 +115,10 @@ export const useSendNextMessage = () => {
const sendRet = await send({ id: flowId }); const sendRet = await send({ id: flowId });
if (receiveMessageError(sendRet)) { if (receiveMessageError(sendRet)) {
message.error(sendRet?.data?.message); message.error(sendRet?.data?.message);
} else {
refetch();
} }
}, [flowId, send]); }, [flowId, refetch, send]);
useEffect(() => { useEffect(() => {
fetchPrologue(); fetchPrologue();