ソースを参照

refactor(workflow): improve loading state rendering and enhance control prompt editor re-rendering logic

tags/2.0.0-beta.1
twwu 2ヶ月前
コミット
313069a63e

+ 1
- 1
web/app/components/tools/utils/to-form-schema.ts ファイルの表示

const value = formSchema.default const value = formSchema.default
newValues[formSchema.variable] = { newValues[formSchema.variable] = {
type: 'constant', type: 'constant',
value: formSchema.default,
value: typeof formSchema.default === 'string' ? formSchema.default.replace(/\n/g, '\\n') : formSchema.default,
} }
newValues[formSchema.variable] = correctInitialData(formSchema.type, newValues[formSchema.variable], value) newValues[formSchema.variable] = correctInitialData(formSchema.type, newValues[formSchema.variable], value)
} }

+ 4
- 0
web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx ファイルの表示

} from '@/app/components/workflow/types' } from '@/app/components/workflow/types'
import { BlockEnum } from '@/app/components/workflow/types' import { BlockEnum } from '@/app/components/workflow/types'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useStore } from '@/app/components/workflow/store'


type MixedVariableTextInputProps = { type MixedVariableTextInputProps = {
readOnly?: boolean readOnly?: boolean
onManageInputField, onManageInputField,
}: MixedVariableTextInputProps) => { }: MixedVariableTextInputProps) => {
const { t } = useTranslation() const { t } = useTranslation()
const controlPromptEditorRerenderKey = useStore(s => s.controlPromptEditorRerenderKey)

return ( return (
<PromptEditor <PromptEditor
key={controlPromptEditorRerenderKey}
wrapperClassName={cn( wrapperClassName={cn(
'w-full rounded-lg border border-transparent bg-components-input-bg-normal px-2 py-1', 'w-full rounded-lg border border-transparent bg-components-input-bg-normal px-2 py-1',
'hover:border-components-input-border-hover hover:bg-components-input-bg-hover', 'hover:border-components-input-border-hover hover:bg-components-input-bg-hover',

+ 5
- 3
web/app/components/workflow/nodes/tool/panel.tsx ファイルの表示

const { schemaTypeDefinitions } = useMatchSchemaType() const { schemaTypeDefinitions } = useMatchSchemaType()


if (isLoading) { if (isLoading) {
return <div className='flex h-[200px] items-center justify-center'>
<Loading />
</div>
return (
<div className='flex h-[200px] items-center justify-center'>
<Loading />
</div>
)
} }


return ( return (

+ 4
- 1
web/app/components/workflow/nodes/tool/use-config.ts ファイルの表示

import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import produce from 'immer' import produce from 'immer'
import { useBoolean } from 'ahooks' import { useBoolean } from 'ahooks'
import { useStore } from '../../store'
import { useStore, useWorkflowStore } from '../../store'
import type { ToolNodeType, ToolVarInputs } from './types' import type { ToolNodeType, ToolVarInputs } from './types'
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud' import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import { canFindTool } from '@/utils' import { canFindTool } from '@/utils'


const useConfig = (id: string, payload: ToolNodeType) => { const useConfig = (id: string, payload: ToolNodeType) => {
const workflowStore = useWorkflowStore()
const { nodesReadOnly: readOnly } = useNodesReadOnly() const { nodesReadOnly: readOnly } = useNodesReadOnly()
const { handleFetchAllTools } = useFetchToolsData() const { handleFetchAllTools } = useFetchToolsData()
const { t } = useTranslation() const { t } = useTranslation()
if (!currTool) if (!currTool)
return return
const inputsWithDefaultValue = formattingParameters() const inputsWithDefaultValue = formattingParameters()
const { setControlPromptEditorRerenderKey } = workflowStore.getState()
setInputs(inputsWithDefaultValue) setInputs(inputsWithDefaultValue)
setTimeout(() => setControlPromptEditorRerenderKey(Date.now()))
}, [currTool]) }, [currTool])


// setting when call // setting when call

読み込み中…
キャンセル
保存