Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions web/src/pages/flow/canvas/node/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import get from 'lodash/get';
import React, { MouseEventHandler, useCallback, useMemo } from 'react';
import JsonView from 'react18-json-view';
import 'react18-json-view/src/style.css';
import { useReplaceIdWithText } from '../../hooks';
import { useGetComponentLabelByValue, useReplaceIdWithText } from '../../hooks';

import {
Popover,
Expand Down Expand Up @@ -39,11 +39,13 @@ export function NextNodePopover({ children, nodeId, name }: IProps) {
[],
);
const output = get(component, ['obj', 'params', 'output'], {});
const { replacedOutput, getNameById } = useReplaceIdWithText(output);
const { replacedOutput } = useReplaceIdWithText(output);
const stopPropagation: MouseEventHandler = useCallback((e) => {
e.stopPropagation();
}, []);

const getLabel = useGetComponentLabelByValue(nodeId);

return (
<Popover>
<PopoverTrigger onClick={stopPropagation} asChild>
Expand Down Expand Up @@ -73,7 +75,7 @@ export function NextNodePopover({ children, nodeId, name }: IProps) {
<TableBody>
{inputs.map((x, idx) => (
<TableRow key={idx}>
<TableCell>{getNameById(x.component_id)}</TableCell>
<TableCell>{getLabel(x.component_id)}</TableCell>
<TableCell className="truncate">{x.content}</TableCell>
</TableRow>
))}
Expand Down
9 changes: 7 additions & 2 deletions web/src/pages/flow/chat/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const useSendNextMessage = () => {
} = useSelectNextMessages();
const { id: flowId } = useParams();
const { handleInputChange, value, setValue } = useHandleMessageInputChange();
const { refetch } = useFetchFlow();

const { send, answer, done } = useSendMessageWithSse(api.runCanvas);

Expand All @@ -75,9 +76,11 @@ export const useSendNextMessage = () => {
// cancel loading
setValue(message.content);
removeLatestMessage();
} else {
refetch(); // pull the message list after sending the message successfully
}
},
[flowId, removeLatestMessage, setValue, send],
[flowId, send, setValue, removeLatestMessage, refetch],
);

const handleSendMessage = useCallback(
Expand Down Expand Up @@ -112,8 +115,10 @@ export const useSendNextMessage = () => {
const sendRet = await send({ id: flowId });
if (receiveMessageError(sendRet)) {
message.error(sendRet?.data?.message);
} else {
refetch();
}
}, [flowId, send]);
}, [flowId, refetch, send]);

useEffect(() => {
fetchPrologue();
Expand Down