mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 15:57:06 +08:00
refactor: remove unused webAppLogout dependency from effect hooks and enhance chat item structure with extra content handling
This commit is contained in:
parent
1cdbfa2539
commit
27da1e72eb
@ -47,7 +47,7 @@ const AuthenticatedLayout = ({ children }: { children: React.ReactNode }) => {
|
|||||||
await webAppLogout(shareCode!)
|
await webAppLogout(shareCode!)
|
||||||
const url = getSigninUrl()
|
const url = getSigninUrl()
|
||||||
router.replace(url)
|
router.replace(url)
|
||||||
}, [getSigninUrl, router, webAppLogout, shareCode])
|
}, [getSigninUrl, router, shareCode])
|
||||||
|
|
||||||
if (appInfoError) {
|
if (appInfoError) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -31,7 +31,7 @@ const Splash: FC<PropsWithChildren> = ({ children }) => {
|
|||||||
await webAppLogout(shareCode!)
|
await webAppLogout(shareCode!)
|
||||||
const url = getSigninUrl()
|
const url = getSigninUrl()
|
||||||
router.replace(url)
|
router.replace(url)
|
||||||
}, [getSigninUrl, router, webAppLogout, shareCode])
|
}, [getSigninUrl, router, shareCode])
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import type { ExtraContent } from '../chat/type'
|
||||||
import type {
|
import type {
|
||||||
Callback,
|
Callback,
|
||||||
ChatConfig,
|
ChatConfig,
|
||||||
@ -9,6 +10,7 @@ import type {
|
|||||||
AppData,
|
AppData,
|
||||||
ConversationItem,
|
ConversationItem,
|
||||||
} from '@/models/share'
|
} from '@/models/share'
|
||||||
|
import type { HumanInputFilledFormData, HumanInputFormData } from '@/types/workflow'
|
||||||
import { useLocalStorageState } from 'ahooks'
|
import { useLocalStorageState } from 'ahooks'
|
||||||
import { noop } from 'es-toolkit/function'
|
import { noop } from 'es-toolkit/function'
|
||||||
import { produce } from 'immer'
|
import { produce } from 'immer'
|
||||||
@ -56,6 +58,22 @@ function getFormattedChatList(messages: any[]) {
|
|||||||
parentMessageId: item.parent_message_id || undefined,
|
parentMessageId: item.parent_message_id || undefined,
|
||||||
})
|
})
|
||||||
const answerFiles = item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || []
|
const answerFiles = item.message_files?.filter((file: any) => file.belongs_to === 'assistant') || []
|
||||||
|
const humanInputFormDataList: HumanInputFormData[] = []
|
||||||
|
const humanInputFilledFormDataList: HumanInputFilledFormData[] = []
|
||||||
|
if (item.status === 'paused') {
|
||||||
|
item.extra_contents?.forEach((content: ExtraContent) => {
|
||||||
|
if (content.type === 'human_input' && !content.submitted) {
|
||||||
|
humanInputFormDataList.push(content.form_definition)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if (item.status === 'normal') {
|
||||||
|
item.extra_contents?.forEach((content: ExtraContent) => {
|
||||||
|
if (content.type === 'human_input' && content.submitted) {
|
||||||
|
humanInputFilledFormDataList.push(content.form_submission_data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
newChatList.push({
|
newChatList.push({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
content: item.answer,
|
content: item.answer,
|
||||||
@ -65,6 +83,8 @@ function getFormattedChatList(messages: any[]) {
|
|||||||
citation: item.retriever_resources,
|
citation: item.retriever_resources,
|
||||||
message_files: getProcessedFilesFromResponse(answerFiles.map((item: any) => ({ ...item, related_id: item.id, upload_file_id: item.upload_file_id }))),
|
message_files: getProcessedFilesFromResponse(answerFiles.map((item: any) => ({ ...item, related_id: item.id, upload_file_id: item.upload_file_id }))),
|
||||||
parentMessageId: `question-${item.id}`,
|
parentMessageId: `question-${item.id}`,
|
||||||
|
humanInputFormDataList,
|
||||||
|
humanInputFilledFormDataList,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return newChatList
|
return newChatList
|
||||||
|
|||||||
@ -144,7 +144,7 @@ const Answer: FC<AnswerProps> = ({
|
|||||||
{hasHumanInputs && (
|
{hasHumanInputs && (
|
||||||
<div className={cn('group relative pr-10', chatAnswerContainerInner)}>
|
<div className={cn('group relative pr-10', chatAnswerContainerInner)}>
|
||||||
<div
|
<div
|
||||||
className={cn('body-lg-regular relative inline-block max-w-full rounded-2xl bg-chat-bubble-bg px-4 py-3 text-text-primary', workflowProcess && 'w-full')}
|
className={cn('body-lg-regular relative inline-block max-w-full rounded-2xl bg-chat-bubble-bg px-4 py-3 text-text-primary', (workflowProcess || hasHumanInputs) && 'w-full')}
|
||||||
>
|
>
|
||||||
{/** Render workflow process */}
|
{/** Render workflow process */}
|
||||||
{
|
{
|
||||||
|
|||||||
@ -68,6 +68,18 @@ export type CitationItem = {
|
|||||||
word_count: number
|
word_count: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ExtraContent
|
||||||
|
= {
|
||||||
|
type: 'human_input'
|
||||||
|
submitted: false
|
||||||
|
form_definition: HumanInputFormData
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: 'human_input'
|
||||||
|
submitted: true
|
||||||
|
form_submission_data: HumanInputFilledFormData
|
||||||
|
}
|
||||||
|
|
||||||
export type IChatItem = {
|
export type IChatItem = {
|
||||||
id: string
|
id: string
|
||||||
content: string
|
content: string
|
||||||
@ -111,6 +123,7 @@ export type IChatItem = {
|
|||||||
// for human input
|
// for human input
|
||||||
humanInputFormDataList?: HumanInputFormData[]
|
humanInputFormDataList?: HumanInputFormData[]
|
||||||
humanInputFilledFormDataList?: HumanInputFilledFormData[]
|
humanInputFilledFormDataList?: HumanInputFilledFormData[]
|
||||||
|
extra_contents?: ExtraContent[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Metadata = {
|
export type Metadata = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user