From 57b6b345678aa26af9d9eead075a87ec40b59ac8 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Fri, 27 Mar 2026 18:03:09 +0800 Subject: [PATCH] fix(web): app file --- web/src/components/Chat/ChatToolbar.tsx | 5 +++-- web/src/views/ApplicationConfig/components/Chat.tsx | 6 +++--- .../ApplicationConfig/components/ConfigHeader.tsx | 9 +++++++-- .../FeaturesConfig/FeaturesConfigModal.tsx | 10 +++++----- web/src/views/ApplicationConfig/types.ts | 3 ++- .../views/Conversation/components/FileUpload.tsx | 4 ++-- web/src/views/Workflow/components/Chat/Chat.tsx | 13 +++++-------- web/src/views/Workflow/hooks/useWorkflowGraph.ts | 7 +++++-- web/src/views/Workflow/index.tsx | 7 +++++-- 9 files changed, 37 insertions(+), 27 deletions(-) diff --git a/web/src/components/Chat/ChatToolbar.tsx b/web/src/components/Chat/ChatToolbar.tsx index 3fbc0e3a..c5db0c4c 100644 --- a/web/src/components/Chat/ChatToolbar.tsx +++ b/web/src/components/Chat/ChatToolbar.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-03-17 14:22:25 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-23 17:42:38 + * @Last Modified time: 2026-03-27 17:54:47 */ // Toolbar component for chat input area, supporting file upload, audio recording, and variable configuration import { useRef, forwardRef, useImperativeHandle, type ReactNode, useEffect } from 'react' @@ -19,6 +19,7 @@ import type { UploadFileListModalRef } from '@/views/Conversation/types' import type { VariableConfigModalRef } from '@/views/Workflow/types' import type { Variable } from '@/views/Workflow/components/Properties/VariableList/types' import { getFileInfoByUrl } from '@/api/fileStorage'; +import { transform_file_type } from '@/views/Conversation/components/FileUpload' // Exposed methods via ref for parent components to access/set form state export interface ChatToolbarRef { @@ -126,7 +127,7 @@ const ChatToolbar = forwardRef(({ status: 'done', name: file_name, size: file_size, - type: content_type, + type: transform_file_type[content_type] || content_type, } : f) form.setFieldValue('files', updated) onFilesChange?.(updated) diff --git a/web/src/views/ApplicationConfig/components/Chat.tsx b/web/src/views/ApplicationConfig/components/Chat.tsx index 940fe7ab..42ae43a9 100644 --- a/web/src/views/ApplicationConfig/components/Chat.tsx +++ b/web/src/views/ApplicationConfig/components/Chat.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-03 16:27:39 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-26 13:41:44 + * @Last Modified time: 2026-03-27 17:59:07 */ /** * Chat debugging component for application testing @@ -224,11 +224,11 @@ const Chat: FC = ({ if (loading || !id) return setLoading(true) setCompareLoading(true) + const files = (fileList || []).filter(item => !['uploading', 'error'].includes(item.status)) handleSave(false) .then(() => { const message = msg if (!message?.trim()) return - const files = (toolbarRef.current?.getFiles() || []).filter(item => !['uploading', 'error'].includes(item.status)) // Validate required variables before sending let isCanSend = true const params: Record = {} @@ -427,11 +427,11 @@ const Chat: FC = ({ if (loading || !id) return setLoading(true) setCompareLoading(true) + const files = (fileList || []).filter(item => !['uploading', 'error'].includes(item.status)) handleSave(false) .then(() => { const message = msg if (!message || message.trim() === '') return - const files = (toolbarRef.current?.getFiles() || []).filter(item => !['uploading', 'error'].includes(item.status)) addUserMessage(message, files) setMessage(undefined) toolbarRef.current?.setFiles([]) diff --git a/web/src/views/ApplicationConfig/components/ConfigHeader.tsx b/web/src/views/ApplicationConfig/components/ConfigHeader.tsx index 5cee841a..5cbe8638 100644 --- a/web/src/views/ApplicationConfig/components/ConfigHeader.tsx +++ b/web/src/views/ApplicationConfig/components/ConfigHeader.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-03 16:27:52 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-24 15:58:23 + * @Last Modified time: 2026-03-27 17:33:44 */ import { type FC, useRef, useMemo, useCallback } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; @@ -212,7 +212,12 @@ const ConfigHeader: FC = ({ } extra={application?.type === 'workflow' && source !== 'sharing' && activeTab === 'arrangement' ? - + ({ ...v, display_name: v.name }))} + /> diff --git a/web/src/views/ApplicationConfig/components/FeaturesConfig/FeaturesConfigModal.tsx b/web/src/views/ApplicationConfig/components/FeaturesConfig/FeaturesConfigModal.tsx index 0100f054..15a8b4e0 100644 --- a/web/src/views/ApplicationConfig/components/FeaturesConfig/FeaturesConfigModal.tsx +++ b/web/src/views/ApplicationConfig/components/FeaturesConfig/FeaturesConfigModal.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-03 16:27:56 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-27 14:24:47 + * @Last Modified time: 2026-03-27 17:32:10 */ /** * Copy Application Modal @@ -75,15 +75,15 @@ const FeaturesConfigModal = forwardRef { let options = fu.document_enabled ? [{ type: 'document', enabled: fu.document_enabled, maxSize: fu.document_max_size_mb }] : [] - if (!capability) return options + if (!capability && source !== 'workflow') return options - if ((capability.includes('vision') || source === 'workflow') && fu.image_enabled) { + if ((capability?.includes('vision') || source === 'workflow') && fu.image_enabled) { options.push({ type: 'image', enabled: fu.image_enabled, maxSize: fu.image_max_size_mb }) } - if ((capability.includes('audio') || source === 'workflow') && fu.audio_enabled) { + if ((capability?.includes('audio') || source === 'workflow') && fu.audio_enabled) { options.push({ type: 'audio', enabled: fu.audio_enabled, maxSize: fu.audio_max_size_mb }) } - if ((capability.includes('video') || source === 'workflow') && fu.video_enabled) { + if ((capability?.includes('video') || source === 'workflow') && fu.video_enabled) { options.push({ type: 'video', enabled: fu.video_enabled, maxSize: fu.video_max_size_mb }) } return options.filter(item => item.enabled) diff --git a/web/src/views/ApplicationConfig/types.ts b/web/src/views/ApplicationConfig/types.ts index e125e73a..6c82ea64 100644 --- a/web/src/views/ApplicationConfig/types.ts +++ b/web/src/views/ApplicationConfig/types.ts @@ -8,7 +8,7 @@ import type { KnowledgeConfig } from './components/Knowledge/types' import type { Variable } from './components/VariableList/types' import type { ToolOption } from './components/ToolList/types' import type { ChatItem } from '@/components/Chat/types' -import type { GraphRef, WorkflowConfig } from '@/views/Workflow/types'; +import type { ChatVariable, GraphRef, WorkflowConfig } from '@/views/Workflow/types'; import type { ApiKey } from '@/views/ApiKeyManagement/types' import type { SkillConfigForm } from './components/Skill/types' import type { Capability } from '@/views/ModelManagement/types' @@ -164,6 +164,7 @@ export interface WorkflowRef { graphRef: GraphRef; /** Add variable */ addVariable: () => void; + chatVariables: ChatVariable[]; config: WorkflowConfig | null; features: WorkflowConfig['features']; handleSaveFeaturesConfig?: (value: FeaturesConfigForm) => void; diff --git a/web/src/views/Conversation/components/FileUpload.tsx b/web/src/views/Conversation/components/FileUpload.tsx index 88cdf83b..70b35328 100644 --- a/web/src/views/Conversation/components/FileUpload.tsx +++ b/web/src/views/Conversation/components/FileUpload.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-06 21:09:42 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-23 17:19:58 + * @Last Modified time: 2026-03-27 17:55:04 */ /** * File Upload Component @@ -59,7 +59,7 @@ interface UploadFilesProps extends Omit { featureConfig: FeaturesConfigForm['file_upload'] } -const transform_file_type = { +export const transform_file_type: Record = { 'text/plain': 'document/text', 'text/markdown': 'document/markdown', 'text/x-markdown': 'document/x-markdown', diff --git a/web/src/views/Workflow/components/Chat/Chat.tsx b/web/src/views/Workflow/components/Chat/Chat.tsx index da2d9620..dad34fc9 100644 --- a/web/src/views/Workflow/components/Chat/Chat.tsx +++ b/web/src/views/Workflow/components/Chat/Chat.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-06 21:10:56 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-25 13:57:40 + * @Last Modified time: 2026-03-27 17:30:47 */ /** * Workflow Chat Component @@ -41,7 +41,9 @@ import type { ChatToolbarRef } from '@/components/Chat/ChatToolbar' import Runtime from './Runtime'; import type { FeaturesConfigForm } from '@/views/ApplicationConfig/types'; -const Chat = forwardRef(({ appId, graphRef, data }, ref) => { +const Chat = forwardRef(({ + appId, graphRef, features +}, ref) => { const { t } = useTranslation() const { message: messageApi } = App.useApp() const toolbarRef = useRef(null) @@ -58,7 +60,6 @@ const Chat = forwardRef(null) const [fileList, setFileList] = useState([]) const [message, setMessage] = useState(undefined) - const [features, setFeatures] = useState({} as FeaturesConfigForm) /** * Opens the chat drawer and loads workflow variables from the start node @@ -67,10 +68,6 @@ const Chat = forwardRef { - if (data?.features && open) setFeatures(data.features) - }, [open, data?.features]) - useEffect(() => { if (open && toolbarReady) { getVariables() @@ -434,7 +431,7 @@ const Chat = forwardRef diff --git a/web/src/views/Workflow/hooks/useWorkflowGraph.ts b/web/src/views/Workflow/hooks/useWorkflowGraph.ts index 135a0891..ddfef27f 100644 --- a/web/src/views/Workflow/hooks/useWorkflowGraph.ts +++ b/web/src/views/Workflow/hooks/useWorkflowGraph.ts @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2026-02-03 15:17:48 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-24 15:01:52 + * @Last Modified time: 2026-03-27 17:11:01 */ import { useRef, useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; @@ -72,6 +72,7 @@ export interface UseWorkflowGraphReturn { handleAddNotes: () => void; handleSaveFeaturesConfig: (value: FeaturesConfigForm) => void; + features?: FeaturesConfigForm; } /** @@ -1212,6 +1213,7 @@ export const useWorkflowGraph = ({ } const handleSaveFeaturesConfig = (value?: FeaturesConfigForm) => { featuresRef.current = value + onFeaturesLoad?.(value) } return { @@ -1233,6 +1235,7 @@ export const useWorkflowGraph = ({ chatVariables, setChatVariables, handleAddNotes, - handleSaveFeaturesConfig + handleSaveFeaturesConfig, + features: featuresRef.current, }; }; diff --git a/web/src/views/Workflow/index.tsx b/web/src/views/Workflow/index.tsx index 1fd6535d..b698e857 100644 --- a/web/src/views/Workflow/index.tsx +++ b/web/src/views/Workflow/index.tsx @@ -34,7 +34,8 @@ const Workflow = forwardRef { @@ -55,8 +56,9 @@ const Workflow = forwardRef