From 945a424fa8ddd2a2a11813238448337179af7d9c Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 17 Jul 2025 18:34:18 +0800 Subject: [PATCH] feat: new result --- .../config/automatic/get-automatic-res.tsx | 90 +++++-------------- .../config/automatic/prompt-toast.tsx | 34 +++++++ .../configuration/config/automatic/result.tsx | 47 ++++++++++ 3 files changed, 105 insertions(+), 66 deletions(-) create mode 100644 web/app/components/app/configuration/config/automatic/prompt-toast.tsx create mode 100644 web/app/components/app/configuration/config/automatic/result.tsx diff --git a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx index e88d59ac39..4df37bbcbb 100644 --- a/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx +++ b/web/app/components/app/configuration/config/automatic/get-automatic-res.tsx @@ -21,14 +21,10 @@ import Button from '@/app/components/base/button' import Textarea from '@/app/components/base/textarea' import Toast from '@/app/components/base/toast' import { generateRule } from '@/service/debug' -import ConfigPrompt from '@/app/components/app/configuration/config-prompt' import type { CompletionParams, Model } from '@/types/app' -import { AppType } from '@/types/app' -import ConfigVar from '@/app/components/app/configuration/config-var' -import GroupName from '@/app/components/app/configuration/base/group-name' +import type { AppType } from '@/types/app' import Loading from '@/app/components/base/loading' import Confirm from '@/app/components/base/confirm' -import { LoveMessage } from '@/app/components/base/icons/src/vender/features' // type import type { AutomaticRes } from '@/service/debug' @@ -44,6 +40,7 @@ import type { Node, NodeOutPutVar } from '@/app/components/workflow/types' import type { GeneratorType } from './types' import { ArrowDownRoundFill } from '@/app/components/base/icons/src/vender/solid/general' import Link from 'next/link' +import Result from './result' const i18nPrefix = 'appDebug.generate' export type IGetAutomaticResProps = { @@ -54,6 +51,8 @@ export type IGetAutomaticResProps = { nodesOutputVars?: NodeOutPutVar[] availableNodes?: Node[] generatorType: GeneratorType + flowId: string + nodeId?: string isBasicMode?: boolean } @@ -80,6 +79,8 @@ const GetAutomaticRes: FC = ({ nodesOutputVars, availableNodes, generatorType, + flowId, + nodeId, isBasicMode, onFinished, }) => { @@ -189,7 +190,7 @@ const GetAutomaticRes: FC = ({ const renderNoData = (
- +
{t('appDebug.generate.newNoDataLine1')}
{t('appDebug.generate.newNoDataLine2')} @@ -241,7 +242,10 @@ const GetAutomaticRes: FC = ({ } } - const [showConfirmOverwrite, setShowConfirmOverwrite] = React.useState(false) + const [isShowConfirmOverwrite, { + setTrue: showConfirmOverwrite, + setFalse: hideShowConfirmOverwrite, + }] = useBoolean(false) const isShowAutoPromptResPlaceholder = () => { return !isLoading && !res @@ -252,7 +256,6 @@ const GetAutomaticRes: FC = ({ isShow={isShow} onClose={onClose} className='min-w-[1140px] !p-0' - closable >
@@ -341,73 +344,28 @@ const GetAutomaticRes: FC = ({
- {(!isLoading && res) && ( + {/* {(!isLoading && res) && ( */} + {
-
{t('appDebug.generate.resTitle')}
-
- - {isBasicMode && ( - <> - {(res?.variables?.length && res?.variables?.length > 0) - ? ( - ({ key, name: key, type: 'string', required: true })) || []} - readonly - /> - ) - : ''} - - {(mode !== AppType.completion && res?.opening_statement) && ( -
- -
-
-
- -
-
- {t('appDebug.feature.conversationOpener.title')} -
-
-
{res.opening_statement}
-
-
- )} - - )} -
- -
- - -
+
- )} + } {isLoading && renderLoading} - {isShowAutoPromptResPlaceholder() && renderNoData} - {showConfirmOverwrite && ( + {isShowAutoPromptResPlaceholder() && !renderNoData} + {isShowConfirmOverwrite && ( { - setShowConfirmOverwrite(false) + hideShowConfirmOverwrite() onFinished(res!) }} - onCancel={() => setShowConfirmOverwrite(false)} + onCancel={hideShowConfirmOverwrite} /> )}
diff --git a/web/app/components/app/configuration/config/automatic/prompt-toast.tsx b/web/app/components/app/configuration/config/automatic/prompt-toast.tsx new file mode 100644 index 0000000000..c94d62d2fb --- /dev/null +++ b/web/app/components/app/configuration/config/automatic/prompt-toast.tsx @@ -0,0 +1,34 @@ +import { RiCloseLine, RiInformation2Fill } from '@remixicon/react' +import { useBoolean } from 'ahooks' +import React from 'react' +import cn from '@/utils/classnames' +type Props = { + className?: string +} +const PromptToast = ({ + className, +}: Props) => { + const [isHide, { + setTrue: hide, + }] = useBoolean(false) + if(isHide) + return + return ( +
+ {/* Background Effect */} +
+
+
+ +

This is the modified prompt with added context.

+
+ +
+ +
+
+
+ ) +} + +export default PromptToast diff --git a/web/app/components/app/configuration/config/automatic/result.tsx b/web/app/components/app/configuration/config/automatic/result.tsx new file mode 100644 index 0000000000..f8e7a5350d --- /dev/null +++ b/web/app/components/app/configuration/config/automatic/result.tsx @@ -0,0 +1,47 @@ +'use client' +import type { FC } from 'react' +import React, { useCallback } from 'react' +import { useTranslation } from 'react-i18next' +import { GeneratorType } from './types' +import PromptToast from './prompt-toast' +import Button from '@/app/components/base/button' + +type Props = { + storageKey: string + onApply: (result: string) => void + generatorType: GeneratorType +} + +const Result: FC = ({ + storageKey, + onApply, + generatorType, +}) => { + const { t } = useTranslation() + const isGeneratorPrompt = generatorType === GeneratorType.prompt + const handleApply = useCallback(() => { + onApply('xxx') + }, [onApply]) + + // todo current version and version list + const current = 'xxxx' + return ( +
+
+
{t('appDebug.generate.resTitle')}
+
+ +
+
+ { + isGeneratorPrompt && ( + + ) + } +
{current}
+
+ ) +} +export default React.memo(Result)