From 74d1eeb4d3793d8c70d184bfc42bc9c7730dcf97 Mon Sep 17 00:00:00 2001 From: balibabu Date: Fri, 8 Nov 2024 17:28:11 +0800 Subject: [PATCH] feat: Automatically save agent page data #3301 (#3302) ### What problem does this PR solve? feat: Automatically save agent page data #3301 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/locales/en.ts | 1 + web/src/locales/zh-traditional.ts | 1 + web/src/locales/zh.ts | 1 + web/src/pages/flow/canvas/index.tsx | 15 ++---- .../pages/flow/canvas/node/relevant-node.tsx | 7 ++- web/src/pages/flow/header/index.less | 2 +- web/src/pages/flow/header/index.tsx | 14 +++-- web/src/pages/flow/hooks.ts | 53 +++++++++++++++++-- web/src/pages/flow/store.ts | 6 ++- web/src/pages/flow/utils.ts | 28 ++++++++++ 10 files changed, 105 insertions(+), 23 deletions(-) diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index c951120bbd0..aa5ef8df874 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -1036,6 +1036,7 @@ The above is the content you need to summarize.`, howUseId: 'How to use agent ID?', content: 'Content', operationResults: 'Operation Results', + autosave: 'Automatically saved', }, footer: { profile: 'All rights reserved @ React', diff --git a/web/src/locales/zh-traditional.ts b/web/src/locales/zh-traditional.ts index db9b953d0b9..df390fba63a 100644 --- a/web/src/locales/zh-traditional.ts +++ b/web/src/locales/zh-traditional.ts @@ -984,6 +984,7 @@ export default { howUseId: '如何使用Agent ID?', content: '內容', operationResults: '運行結果', + autosave: '已自動儲存', }, footer: { profile: '“保留所有權利 @ react”', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 780a3499a4c..41098f4c493 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -1004,6 +1004,7 @@ export default { howUseId: '如何使用Agent ID?', content: '内容', operationResults: '运行结果', + autosave: '已自动保存', }, footer: { profile: 'All rights reserved @ React', diff --git a/web/src/pages/flow/canvas/index.tsx b/web/src/pages/flow/canvas/index.tsx index d92420e580d..c38f6e8efd3 100644 --- a/web/src/pages/flow/canvas/index.tsx +++ b/web/src/pages/flow/canvas/index.tsx @@ -128,6 +128,9 @@ function FlowCanvas({ chatDrawerVisible, hideChatDrawer }: IProps) { onSelectionChange={onSelectionChange} nodeOrigin={[0.5, 0]} isValidConnection={isValidConnection} + onChangeCapture={(...params) => { + console.info('onChangeCapture:', ...params); + }} onChange={(...params) => { console.info('params:', ...params); }} @@ -140,18 +143,6 @@ function FlowCanvas({ chatDrawerVisible, hideChatDrawer }: IProps) { }, }} deleteKeyCode={['Delete', 'Backspace']} - onPaste={(...params) => { - console.info('onPaste:', ...params); - }} - onPasteCapture={(...params) => { - console.info('onPasteCapture:', ...params); - }} - onCopy={(...params) => { - console.info('onCopy:', ...params); - }} - onCopyCapture={(...params) => { - console.info('onCopyCapture:', ...params); - }} > diff --git a/web/src/pages/flow/canvas/node/relevant-node.tsx b/web/src/pages/flow/canvas/node/relevant-node.tsx index 02407fc4dfe..5e22517591e 100644 --- a/web/src/pages/flow/canvas/node/relevant-node.tsx +++ b/web/src/pages/flow/canvas/node/relevant-node.tsx @@ -5,12 +5,15 @@ import { NodeData } from '../../interface'; import { RightHandleStyle } from './handle-icon'; import { get } from 'lodash'; +import { useReplaceIdWithName } from '../../hooks'; import styles from './index.less'; import NodeHeader from './node-header'; export function RelevantNode({ id, data, selected }: NodeProps) { const yes = get(data, 'form.yes'); const no = get(data, 'form.no'); + const replaceIdWithName = useReplaceIdWithName(); + return (
) {
Yes
-
{yes}
+
{replaceIdWithName(yes)}
No
-
{no}
+
{replaceIdWithName(no)}
diff --git a/web/src/pages/flow/header/index.less b/web/src/pages/flow/header/index.less index 5d637286e76..1d78c87d29f 100644 --- a/web/src/pages/flow/header/index.less +++ b/web/src/pages/flow/header/index.less @@ -1,3 +1,3 @@ .flowHeader { - padding: 0 20px; + padding: 10px 20px; } diff --git a/web/src/pages/flow/header/index.tsx b/web/src/pages/flow/header/index.tsx index e03b03a7722..70ef319ea80 100644 --- a/web/src/pages/flow/header/index.tsx +++ b/web/src/pages/flow/header/index.tsx @@ -5,7 +5,11 @@ import { ArrowLeftOutlined } from '@ant-design/icons'; import { Button, Flex, Space } from 'antd'; import { Link, useParams } from 'umi'; import FlowIdModal from '../flow-id-modal'; -import { useSaveGraph, useSaveGraphBeforeOpeningDebugDrawer } from '../hooks'; +import { + useSaveGraph, + useSaveGraphBeforeOpeningDebugDrawer, + useWatchAgentChange, +} from '../hooks'; import styles from './index.less'; interface IProps { @@ -20,10 +24,11 @@ const FlowHeader = ({ showChatDrawer }: IProps) => { const { visible: overviewVisible, hideModal: hideOverviewModal, - showModal: showOverviewModal, + // showModal: showOverviewModal, } = useSetModalState(); const { visible, hideModal, showModal } = useSetModalState(); const { id } = useParams(); + const time = useWatchAgentChange(); return ( <> @@ -37,7 +42,10 @@ const FlowHeader = ({ showChatDrawer }: IProps) => { -

{data.title}

+
+ {data.title} + 已自动保存 {time} +