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
aba0789f
Commit
aba0789f
authored
Mar 16, 2026
by
Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:auto submit
parent
778f325d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
src/layouts/HistoryBar/components/HistoryBarList/index.tsx
+18
-1
src/pages/Chat/Chat.tsx
+20
-2
No files found.
src/layouts/HistoryBar/components/HistoryBarList/index.tsx
View file @
aba0789f
...
...
@@ -8,7 +8,7 @@ import EmptyIcon from '@/assets/svg/empty.svg?react'
import
{
useAppDispatch
,
useAppSelector
}
from
'@/store/hook'
import
type
{
Conversation
}
from
'@/types/conversation'
import
{
processConversationData
}
from
'@/store/conversationSlice.helper'
import
{
clearCurrentToolId
,
setCurrentToolId
}
from
'@/store/conversationSlice'
import
{
clearCurrentToolId
,
clearShouldSendQuestion
,
setCurrentToolId
,
setShouldSendQuestion
}
from
'@/store/conversationSlice'
import
{
isMobile
}
from
'@/utils'
interface
HistoryBarListProps
{
...
...
@@ -39,6 +39,23 @@ export const HistoryBarList: React.FC<HistoryBarListProps> = ({ searchValue, onS
sessionStorage
.
removeItem
(
'currentToolId'
)
dispatch
(
clearCurrentToolId
())
}
// 仅当历史记录为“提质增效”时,进入对话页后自动触发一次提问接口
// 用空格字符串触发 shouldSendQuestion 的监听,但不会在 UI 中新增用户问题气泡(question.trim() 为 false)。
const
isQualityImprovement
=
conversation
.
toolId
===
'6712395743241'
if
(
isQualityImprovement
)
{
const
autoShouldSendQuestion
=
' '
dispatch
(
setShouldSendQuestion
(
autoShouldSendQuestion
))
console
.
log
(
'[HistoryBarList] shouldSendQuestion 000000:'
,
{
conversationId
:
conversation
.
conversationId
,
toolId
:
conversation
.
toolId
,
shouldSendQuestion
:
autoShouldSendQuestion
,
})
}
else
{
// 避免上一次残留的 shouldSendQuestion 误触发自动提问
dispatch
(
clearShouldSendQuestion
())
}
// 直接导航到历史记录,不设置shouldSendQuestion
// 在 URL 中拼接 toolId 作为查询参数,以便刷新页面后仍能保留
const
url
=
conversation
.
toolId
...
...
src/pages/Chat/Chat.tsx
View file @
aba0789f
...
...
@@ -124,6 +124,17 @@ export const Chat: React.FC = () => {
console
.
debug
(
'[Chat] 当前链接 / 缓存 toolId:'
,
debugInfo
)
},
[
debugInfo
])
// 调试:观察 shouldSendQuestion 在对话页的变化
useEffect
(()
=>
{
console
.
log
(
'[Chat] shouldSendQuestion changed 111111:'
,
{
conversationIdFromRoute
:
id
,
shouldSendQuestion
,
currentToolId
,
isLoading
,
allItemsLength
:
allItems
.
length
,
})
},
[
id
,
shouldSendQuestion
,
currentToolId
,
isLoading
,
allItems
.
length
])
// 历史记录点击时将 toolId 通过路由 state 传入,优先使用该值快速同步高亮
useEffect
(()
=>
{
// 保存从 location.state 传递的 toolId 到 ref
...
...
@@ -717,7 +728,8 @@ export const Chat: React.FC = () => {
dispatch
(
clearShouldSendQuestion
())
// 延迟发送,确保状态已更新
setTimeout
(()
=>
{
handleSubmitQuestion
(
questionToSend
,
undefined
,
currentToolId
)
// 自动触发提问时,不传 workFlowSessionId(与提质增效按钮自动调用保持一致)
handleSubmitQuestion
(
questionToSend
,
undefined
,
currentToolId
,
{
isReask
:
true
})
},
100
)
}
}
...
...
@@ -820,6 +832,11 @@ export const Chat: React.FC = () => {
const
canSend
=
historyLoadedRef
.
current
.
conversationId
===
currentIdRef
.
current
||
allItems
.
length
<=
1
if
(
canSend
)
{
const
questionToSend
=
shouldSendQuestion
console
.
log
(
'[Chat] auto send triggered (shouldSendQuestion):'
,
{
conversationId
:
currentIdRef
.
current
,
question
:
questionToSend
,
currentToolId
,
})
lastSentQuestionRef
.
current
=
questionToSend
pendingQuestionRef
.
current
=
null
// 立即清除shouldSendQuestion,防止重复发送
...
...
@@ -827,7 +844,8 @@ export const Chat: React.FC = () => {
// 确保历史记录加载完成后再发送问题
setTimeout
(()
=>
{
console
.
log
(
'[Chat] 执行自动发送问题:'
,
questionToSend
)
handleSubmitQuestion
(
questionToSend
,
undefined
,
currentToolId
)
// 自动触发提问时,不传 workFlowSessionId(与提质增效按钮自动调用保持一致)
handleSubmitQuestion
(
questionToSend
,
undefined
,
currentToolId
,
{
isReask
:
true
})
},
100
)
}
else
{
...
...
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