mirror of
https://github.com/langgenius/dify.git
synced 2026-10-16 15:35:32 +08:00
refactor(web): drop pending-form matching from restored chat history
A form is either pending or submitted in one history response, so matching a submitted form ID against the pending list can never succeed. Pass the form definition straight through and drop test setup that no longer affects the rendered components.
This commit is contained in:
@@ -90,21 +90,16 @@ function getFormattedChatList(messages: any[]) {
|
||||
}
|
||||
|
||||
if (!('form_submission_data' in content) || !content.form_submission_data) return
|
||||
// Legacy submissions without a definition expose no form ID. Keep a history-only
|
||||
// identity for their cards without matching or removing a live pending form.
|
||||
// Legacy submissions without a definition expose no form ID, so give their
|
||||
// cards a history-only identity.
|
||||
const formId =
|
||||
formDefinition?.form_id ??
|
||||
`${content.workflow_run_id ?? item.id}:${content.form_submission_data.node_id}:${contentIndex}`
|
||||
const currentFormIndex = humanInputFormDataList.findIndex((item) => item.form_id === formId)
|
||||
const requiredFormData =
|
||||
formDefinition ||
|
||||
(currentFormIndex > -1 ? humanInputFormDataList[currentFormIndex] : undefined)
|
||||
if (currentFormIndex > -1) humanInputFormDataList.splice(currentFormIndex, 1)
|
||||
workflowRunId = content.workflow_run_id || workflowRunId
|
||||
humanInputFilledFormDataList.push(
|
||||
enrichSubmittedHumanInputFormData(
|
||||
{ ...content.form_submission_data, form_id: formId },
|
||||
requiredFormData,
|
||||
formDefinition,
|
||||
),
|
||||
)
|
||||
})
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
import type { HumanInputFilledFormData } from '@/types/workflow'
|
||||
import { screen } from '@testing-library/react'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { renderWithAccountProfile as render } from '@/test/console/account-profile'
|
||||
import HumanInputFilledFormList from '../human-input-filled-form-list'
|
||||
|
||||
it('keeps expansion with the same form when same-Tool submissions are reordered', async () => {
|
||||
|
||||
@@ -9,7 +9,6 @@ vi.mock('../../hooks/use-workflow', () => ({
|
||||
|
||||
describe('RunningTitle', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
mockIsChatMode = false
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user