feat: enhance human input form handling by adding placeholder values and new workflow event handlers

This commit is contained in:
twwu 2026-01-15 18:22:11 +08:00
parent 61c7fdc614
commit 91c35c2f0a
3 changed files with 25 additions and 8 deletions

View File

@ -24,6 +24,7 @@ export type FormData = {
site: any
form_content: string
inputs: FormInputItem[]
placeholder_values: Record<string, string>
user_actions: UserAction[]
expiration_time: number
}
@ -235,6 +236,7 @@ const FormContent = () => {
formInputFields={formData.inputs}
inputs={inputs}
onInputChange={handleInputsChange}
resolvedPlaceholderValues={formData.placeholder_values}
/>
))}
<div className="flex flex-wrap gap-1 py-1">

View File

@ -499,6 +499,27 @@ export const useWorkflowRun = () => {
if (audioPlayer)
audioPlayer.playAudioWithAudio(audio, false)
},
onWorkflowPaused: (params) => {
handleWorkflowPaused()
if (onWorkflowPaused)
onWorkflowPaused(params)
const url = `/workflow/${params.workflow_run_id}/events`
sseGet(
url,
{},
baseSseOptions,
)
},
onHumanInputRequired: (params) => {
handleWorkflowNodeHumanInputRequired(params)
if (onHumanInputRequired)
onHumanInputRequired(params)
},
onHumanInputFormFilled: (params) => {
handleWorkflowNodeHumanInputFormFilled(params)
if (onHumanInputFormFilled)
onHumanInputFormFilled(params)
},
onError: wrappedOnError,
onCompleted: wrappedOnCompleted,
}

View File

@ -10,9 +10,9 @@ import type {
IOnTTSEnd,
IOtherOptions,
} from './base'
import type { FormData as HumanInputFormData } from '@/app/(humanInputLayout)/form/[token]/form'
import type { FeedbackType } from '@/app/components/base/chat/chat/type'
import type { ChatConfig } from '@/app/components/base/chat/types'
import type { FormInputItem, UserAction } from '@/app/components/workflow/nodes/human-input/types'
import type { AccessMode } from '@/models/access-control'
import type {
AppConversationData,
@ -280,13 +280,7 @@ export const getAppAccessModeByAppCode = (appCode: string) => {
}
export const getHumanInputForm = (token: string) => {
return get<{
site: any
form_content: string
inputs: FormInputItem[]
user_actions: UserAction[]
expiration_time: number
}>(`/form/human_input/${token}`)
return get<HumanInputFormData>(`/form/human_input/${token}`)
}
export const submitHumanInputForm = (token: string, data: {