Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sdream-ai-fe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
侯明涛
sdream-ai-fe
Commits
2d419f61
Commit
2d419f61
authored
Nov 28, 2025
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix conversation toolId handling
parent
1912c563
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
9 deletions
+17
-9
src/components/ChatEditor/index.tsx
+1
-1
src/pages/Chat/Chat.tsx
+6
-6
src/pages/Collect/Collect.tsx
+4
-0
src/store/conversationSlice.ts
+6
-2
No files found.
src/components/ChatEditor/index.tsx
View file @
2d419f61
...
...
@@ -171,7 +171,7 @@ const ChatEditorBase: React.FC<ChatEditorProps & WithAuthProps> = ({ checkAuth,
setIsToolBtnActive
(
false
)
try
{
await
dispatch
(
createConversation
({
conversationData
:
{},
conversationData
:
{
toolId
:
tool
.
toolId
},
shouldNavigate
:
true
,
shouldSendQuestion
:
''
,
})).
unwrap
()
...
...
src/pages/Chat/Chat.tsx
View file @
2d419f61
...
...
@@ -206,7 +206,8 @@ export const Chat: React.FC = () => {
setIsLoading
(
true
)
try
{
const
res
=
await
fetchUserQaRecordPage
(
conversationId
)
const
messages
=
[{
role
:
'system'
}
as
ChatRecord
,
...
processApiResponse
(
res
.
data
)]
const
qaRecords
=
res
.
data
||
[]
const
messages
=
[{
role
:
'system'
}
as
ChatRecord
,
...
processApiResponse
(
qaRecords
)]
// 处理历史记录中的参考文档标记
const
processedMessages
=
messages
.
map
((
item
)
=>
{
if
(
item
.
role
===
'ai'
&&
item
.
answerList
?.[
0
]?.
answer
)
{
...
...
@@ -224,12 +225,11 @@ export const Chat: React.FC = () => {
return
item
})
setAllItems
(
processedMessages
)
const
latestToolRecord
=
[...
processedMessages
].
reverse
().
find
(
item
=>
item
.
role
===
'ai'
&&
item
.
toolId
!==
undefined
)
const
trimmedToolId
=
latestToolRecord
?.
toolId
?.
trim
?.()
const
hasQaRecords
=
processedMessages
.
some
(
item
=>
item
.
role
!==
'system'
)
const
latestToolId
=
[...
qaRecords
].
reverse
().
find
(
item
=>
Boolean
(
item
.
toolId
))?.
toolId
?.
trim
?.()
const
hasQaRecords
=
qaRecords
.
length
>
0
if
(
hasQaRecords
)
{
if
(
trimmed
ToolId
)
{
dispatch
(
setCurrentToolId
(
trimmed
ToolId
))
if
(
latest
ToolId
)
{
dispatch
(
setCurrentToolId
(
latest
ToolId
))
}
else
{
dispatch
(
clearCurrentToolId
())
...
...
src/pages/Collect/Collect.tsx
View file @
2d419f61
...
...
@@ -85,6 +85,10 @@ export const Collect: React.FC = () => {
// 添加返回上一页的函数
const
handleGoBack
=
()
=>
{
if
(
window
.
history
.
length
>
1
)
{
navigate
(
-
1
)
return
}
const
conversationId
=
sessionStorage
.
getItem
(
'currentConversationId'
)
||
''
navigate
(
`/chat/
${
conversationId
}
`
,
{
state
:
{
fromCollect
:
true
}
})
}
...
...
src/store/conversationSlice.ts
View file @
2d419f61
...
...
@@ -64,8 +64,12 @@ export const createConversation = createAsyncThunk<
'conversation/createConversation'
,
async
({
conversationData
,
shouldNavigate
,
shouldSendQuestion
},
{
dispatch
,
getState
})
=>
{
const
state
=
getState
()
const
toolId
=
state
.
conversation
.
currentToolId
||
''
const
response
=
await
fetchCreateConversation
({
...
conversationData
,
toolId
})
const
resolvedToolId
=
conversationData
.
toolId
??
state
.
conversation
.
currentToolId
const
requestPayload
=
{
...
conversationData
,
...(
resolvedToolId
?
{
toolId
:
resolvedToolId
}
:
{}),
}
const
response
=
await
fetchCreateConversation
(
requestPayload
)
const
newConversation
=
response
.
data
dispatch
(
fetchConversations
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment