fix: 修复流式输出展开状态被覆盖
- 保留智能体思考内容的手动展开与关闭选择 - 工作流试运行默认跟随当前节点,并允许用户自由多开或关闭
This commit is contained in:
@@ -7,7 +7,7 @@ import type {
|
||||
ChatTimelineToolApprovalPayload,
|
||||
} from './types';
|
||||
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import ChatThinkingBlock from '../chat-thinking/ChatThinkingBlock.vue';
|
||||
import ChatErrorNotice from './ChatErrorNotice.vue';
|
||||
@@ -43,6 +43,8 @@ const emit = defineEmits<{
|
||||
const messageItem = computed(() =>
|
||||
props.item.type === 'message' ? props.item : undefined,
|
||||
);
|
||||
// 流式快照会替换消息对象,用户手动选择需要由稳定的组件实例单独保留。
|
||||
const thinkingExpandedOverrides = ref<Record<string, boolean>>({});
|
||||
|
||||
const alignmentClass = computed(() => {
|
||||
if (props.item.type === 'message' && props.item.role === 'user') {
|
||||
@@ -115,11 +117,25 @@ function updateThinkingExpanded(partId: string, expanded: boolean) {
|
||||
}
|
||||
const part = item.parts.find((current) => current.id === partId);
|
||||
if (part?.type === 'thinking') {
|
||||
thinkingExpandedOverrides.value = {
|
||||
...thinkingExpandedOverrides.value,
|
||||
[partId]: expanded,
|
||||
};
|
||||
emit('thinkingToggle');
|
||||
part.expanded = expanded;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveThinkingExpanded(
|
||||
part: Extract<ChatTimelineMessagePart, { type: 'thinking' }>,
|
||||
) {
|
||||
return (
|
||||
thinkingExpandedOverrides.value[part.id] ??
|
||||
part.expanded ??
|
||||
part.status === 'thinking'
|
||||
);
|
||||
}
|
||||
|
||||
function handleCopyAction() {
|
||||
const item = messageItem.value;
|
||||
if (!item || !props.copyAction) {
|
||||
@@ -149,7 +165,7 @@ function handleCopyAction() {
|
||||
<ChatThinkingBlock
|
||||
v-if="part.type === 'thinking'"
|
||||
:content="part.content"
|
||||
:expanded="part.expanded ?? part.status === 'thinking'"
|
||||
:expanded="resolveThinkingExpanded(part)"
|
||||
:status="part.status"
|
||||
class="chat-timeline-item__thinking"
|
||||
readonly
|
||||
|
||||
Reference in New Issue
Block a user