bugfix: restore会话历史

This commit is contained in:
2026-03-02 13:54:52 +08:00
parent 8912e1fa74
commit e857f54eb1
2 changed files with 33 additions and 28 deletions

View File

@@ -26,7 +26,7 @@
import Input from '../../components/Input.vue' import Input from '../../components/Input.vue'
import { fetchAgentReply } from '@/api/agent' import { fetchAgentReply } from '@/api/agent'
import type { AgentParamsType } from '@/api/agent' import type { AgentParamsType } from '@/api/agent'
import { useUserInfoStore, useProjectStore, } from '@/stores' import { useUserInfoStore, useProjectStore } from '@/stores'
import { useAgentStore } from '@/stores/agent' import { useAgentStore } from '@/stores/agent'
const userStore = useUserInfoStore() const userStore = useUserInfoStore()
@@ -252,7 +252,7 @@
// console.log('dataLInes', dataLines) // console.log('dataLInes', dataLines)
if (isNodeIdEvent) { if (isNodeIdEvent) {
params.versionID = dataLines[0] params.versionID = dataLines[0]
projectStore.setProject({nodeId:dataLines[0]}) projectStore.setProject({ nodeId: dataLines[0] })
} }
if (dataLines.length === 0) continue if (dataLines.length === 0) continue
@@ -367,31 +367,34 @@
const ancestorsList = [] const ancestorsList = []
if (ancestors) { if (ancestors) {
ancestors.forEach((item) => { ancestors.forEach((item) => {
const list = item.dialogue.map((el, index) => { const list =
if (el.image_url) { item.dialogue?.map((el, index) => {
imgList.push(el.image_url) if (el.image_url) {
} imgList.push(el.image_url)
return { }
...el, return {
text: el.content, ...el,
isUser: el.role === 'user', text: el.content,
id: index + 1 isUser: el.role === 'user',
} id: index + 1
}) }
}) || []
ancestorsList.push(...list) ancestorsList.push(...list)
}) })
} }
const currentList = current.dialogue.map((item, index) => { const currentList =
if (item.image_url) { current?.dialogue?.map((item, index) => {
imgList.push(item.image_url) if (item.image_url) {
} imgList.push(item.image_url)
return { }
...item, return {
text: item.content, ...item,
isUser: item.role === 'user', text: item.content,
id: index + 1 + ancestorsList.length isUser: item.role === 'user',
} id: index + 1 + ancestorsList.length
}) }
}) || []
messageList.value = [...ancestorsList, ...currentList] messageList.value = [...ancestorsList, ...currentList]
params.versionID = current.id params.versionID = current.id
sketchList.value = imgList sketchList.value = imgList

View File

@@ -49,7 +49,9 @@
const handleRestore = () => { const handleRestore = () => {
// agentRef.value?.inputRef?.addReportTag('Restore') // agentRef.value?.inputRef?.addReportTag('Restore')
clearNodeChat({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then( clearNodeChat({ projectId: projectStore.state.id, id: projectStore.state.nodeId }).then(
(res) => {} (res) => {
agentRef.value.setChatInfo(res)
}
) )
} }
const handleSelectNode = () => { const handleSelectNode = () => {
@@ -64,11 +66,11 @@
const handleGetProjectInfoAndHistory = () => { const handleGetProjectInfoAndHistory = () => {
getProjectInfo({ id: route.params.id }).then((res) => { getProjectInfo({ id: route.params.id }).then((res) => {
if(res?.conversation)agentRef.value.setChatInfo(res.conversation) if (res?.conversation) agentRef.value.setChatInfo(res.conversation)
let data = res?.project || res let data = res?.project || res
if(data?.latestNodeId)data.nodeId = data.latestNodeId if (data?.latestNodeId) data.nodeId = data.latestNodeId
projectStore.setProject({ projectStore.setProject({
...data, ...data
}) })
}) })
} }