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
b14e994b
Commit
b14e994b
authored
Jan 23, 2026
by
weiyudumei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 移除流式返回时的UI隐藏逻辑,只隐藏历史记录,正常问答显示UI
parent
efae372f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
16 deletions
+6
-16
src/pages/Chat/components/ChatItem/ChatAnswerBox.tsx
+1
-6
src/pages/Chat/components/ChatItem/ChatAnswerParser.tsx
+1
-3
src/pages/Chat/components/ChatItem/ChatAnswerShower.tsx
+1
-3
src/pages/ChatTactics/TacticsChat.tsx
+3
-4
No files found.
src/pages/Chat/components/ChatItem/ChatAnswerBox.tsx
View file @
b14e994b
...
@@ -60,11 +60,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
...
@@ -60,11 +60,7 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
// 当前默认始终展示点赞 / 点踩 / 复制等操作区(是否展示由下层基于卡片类型自行决定)
// 当前默认始终展示点赞 / 点踩 / 复制等操作区(是否展示由下层基于卡片类型自行决定)
const
shouldHideOperate
=
false
const
shouldHideOperate
=
false
// 如果 firstQaFlag 为 true 且存在 workflow 卡片,隐藏整个 chatItem(用户不需要看到这次的结果)
// 不再隐藏流式返回的 chatItem,只隐藏历史记录(在 Chat.tsx 和 TacticsChat.tsx 中处理)
// 注意:历史记录(isShow === true)不会渲染 CardWorkflowForm,不会自动提交
// 只有流式返回的新记录(isShow === false)才会渲染 CardWorkflowForm 并执行自动提交
const
hasWorkflowCard
=
(
item
.
cardList
||
[]).
some
(
attachment
=>
attachment
.
type
===
'card-workflow'
)
const
shouldHideChatItem
=
item
.
firstQaFlag
===
true
&&
hasWorkflowCard
// 创建包装函数,从会话历史中找到最后一个有 workFlowSessionId 的答案,并在追问时传递
// 创建包装函数,从会话历史中找到最后一个有 workFlowSessionId 的答案,并在追问时传递
const
handleSubmitQuestionWithWorkflow
=
(
question
:
string
,
productCode
?:
string
)
=>
{
const
handleSubmitQuestionWithWorkflow
=
(
question
:
string
,
productCode
?:
string
)
=>
{
...
@@ -89,7 +85,6 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
...
@@ -89,7 +85,6 @@ export const ChatAnswerBox: React.FC<ChatAnswerBoxProps> = ({ record, showIndex,
<
div
<
div
className=
"chatItemBotContainer w-full"
className=
"chatItemBotContainer w-full"
key=
{
`${item.recordId}-${index}`
}
key=
{
`${item.recordId}-${index}`
}
style=
{
shouldHideChatItem
?
{
visibility
:
'hidden'
,
height
:
0
,
overflow
:
'hidden'
,
margin
:
0
,
padding
:
0
}
:
undefined
}
>
>
<
div
className=
"flex"
>
<
div
className=
"flex"
>
<
Avatar
<
Avatar
...
...
src/pages/Chat/components/ChatItem/ChatAnswerParser.tsx
View file @
b14e994b
...
@@ -202,9 +202,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
...
@@ -202,9 +202,7 @@ export const ChatAnswerParser: React.FC<ChatAnswerParserProps> = ({ isLastAnswer
</
MarkdownDetail
>
</
MarkdownDetail
>
</
div
>
</
div
>
)
}
)
}
{
/* ChatAnswerParser 用于流式返回的新记录(isShow === false),即使 firstQaFlag === true 也要渲染 ChatAnswerAttachment,确保自动提交逻辑能执行
{
!
isTyping
如果 firstQaFlag 为 true 且存在 workflow 卡片,即使 isTyping 为 true 也要渲染 ChatAnswerAttachment */
}
{
((
!
isTyping
)
||
(
answer
.
firstQaFlag
===
true
&&
(
answer
.
cardList
||
[]).
some
(
attachment
=>
attachment
.
type
===
'card-workflow'
)))
&&
answer
.
cardList
&&
answer
.
cardList
&&
answer
.
cardList
?.
length
!==
0
&&
answer
.
cardList
?.
length
!==
0
&&
(
&&
(
...
...
src/pages/Chat/components/ChatItem/ChatAnswerShower.tsx
View file @
b14e994b
...
@@ -28,9 +28,7 @@ export const ChatAnswerShower: React.FC<ChatAnswerShowerProps> = ({ answer, isLa
...
@@ -28,9 +28,7 @@ export const ChatAnswerShower: React.FC<ChatAnswerShowerProps> = ({ answer, isLa
</
MarkdownDetail
>
</
MarkdownDetail
>
</
div
>
</
div
>
)
}
)
}
{
/* 历史记录(isShow === true)且 firstQaFlag === true 时,不渲染 ChatAnswerAttachment(不需要自动提交)
{
answer
.
cardList
&&
answer
.
cardList
?.
length
!==
0
&&
(
流式返回的新记录(isShow === false)即使 firstQaFlag === true 也要渲染,确保自动提交逻辑能执行 */
}
{
answer
.
cardList
&&
answer
.
cardList
?.
length
!==
0
&&
!
(
answer
.
isShow
===
true
&&
answer
.
firstQaFlag
===
true
)
&&
(
<
ChatAnswerAttachment
<
ChatAnswerAttachment
onSubmitQuestion=
{
onSubmitQuestion
}
onSubmitQuestion=
{
onSubmitQuestion
}
isLastAnswer=
{
isLastAnswer
}
isLastAnswer=
{
isLastAnswer
}
...
...
src/pages/ChatTactics/TacticsChat.tsx
View file @
b14e994b
...
@@ -1195,10 +1195,8 @@ export const TacticsChat: React.FC = () => {
...
@@ -1195,10 +1195,8 @@ export const TacticsChat: React.FC = () => {
if
(
record
.
role
===
'user'
&&
!
record
.
question
)
{
if
(
record
.
role
===
'user'
&&
!
record
.
question
)
{
return
null
return
null
}
}
// 如果历史记录中 firstQaFlag 为 true,则不展示该条 chatItem
// 如果历史记录中 firstQaFlag 为 true,隐藏 UI 但保留组件渲染
if
(
record
.
role
===
'ai'
&&
record
.
answerList
?.[
0
]?.
firstQaFlag
===
true
)
{
const
shouldHideHistoryItem
=
record
.
role
===
'ai'
&&
record
.
answerList
?.[
0
]?.
firstQaFlag
===
true
return
null
}
const
matchedDivider
=
historyDividers
.
find
(
divider
=>
divider
.
index
===
index
+
1
)
const
matchedDivider
=
historyDividers
.
find
(
divider
=>
divider
.
index
===
index
+
1
)
const
recordId
=
record
.
answerList
?.[
0
]?.
recordId
||
record
.
groupId
const
recordId
=
record
.
answerList
?.[
0
]?.
recordId
||
record
.
groupId
const
uniqueKey
=
recordId
const
uniqueKey
=
recordId
...
@@ -1216,6 +1214,7 @@ export const TacticsChat: React.FC = () => {
...
@@ -1216,6 +1214,7 @@ export const TacticsChat: React.FC = () => {
)
}
)
}
<
div
<
div
className=
"w-full chatItem mx-auto"
className=
"w-full chatItem mx-auto"
style=
{
shouldHideHistoryItem
?
{
visibility
:
'hidden'
,
height
:
0
,
overflow
:
'hidden'
,
margin
:
0
,
padding
:
0
}
:
undefined
}
>
>
{
record
.
role
===
'system'
&&
<
TacticsWelcome
cleared=
{
hasCleared
}
/>
}
{
record
.
role
===
'system'
&&
<
TacticsWelcome
cleared=
{
hasCleared
}
/>
}
{
record
.
role
===
'user'
&&
<
ChatItemUser
record=
{
record
}
/>
}
{
record
.
role
===
'user'
&&
<
ChatItemUser
record=
{
record
}
/>
}
...
...
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