Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions src/renderer/src/components/message/MessageList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import { useMessageScroll } from '@/composables/message/useMessageScroll'
import { useCleanDialog } from '@/composables/message/useCleanDialog'
import { useMessageMinimap } from '@/composables/message/useMessageMinimap'
import { useMessageCapture } from '@/composables/message/useMessageCapture'
import { useSendButtonState } from '@/components/chat-input/composables/useSendButtonState'
import { DynamicScroller, DynamicScrollerItem } from 'vue-virtual-scroller'
import { getAllMessageDomInfo, getMessageDomInfo } from '@/lib/messageRuntimeCache'

Expand Down Expand Up @@ -129,6 +130,16 @@ const shouldAutoFollow = ref(true)
const traceMessageId = ref<string | null>(null)
let highlightRefreshTimer: number | null = null

// === Streaming State ===
const inputText = ref('')
const currentContextLength = ref(0)
const { isStreaming } = useSendButtonState({
variant: 'chat',
inputText,
currentContextLength,
contextLength: computed(() => chatStore.chatConfig.contextLength)
})

// === Composable Integrations ===
// Scroll management
const scroll = useMessageScroll({
Expand Down Expand Up @@ -159,16 +170,22 @@ const capture = useMessageCapture()
// Message retry

const minimapMessages = computed(() => {
const mapped = props.items.map((item) => {
if (item.message) return item.message
return {
id: item.id,
role: 'user',
conversationId: chatStore.getActiveThreadId() ?? '',
content: { text: '', files: [], links: [], think: false, search: false },
timestamp: Date.now()
} as unknown as Message
})
// 如果正在 streaming,排除 pending 状态的消息,避免 minimap 频繁重新计算
const mapped = props.items
.filter((item) => {
if (!isStreaming.value) return true
return !item.message || item.message.status !== 'pending'
})
Comment on lines +173 to +178
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Chinese comment should be translated to English.

Per coding guidelines, all comments must be in English.

Suggested fix
-  // 如果正在 streaming,排除 pending 状态的消息,避免 minimap 频繁重新计算
+  // During streaming, exclude pending messages to prevent frequent minimap recalculations
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 如果正在 streaming,排除 pending 状态的消息,避免 minimap 频繁重新计算
const mapped = props.items
.filter((item) => {
if (!isStreaming.value) return true
return !item.message || item.message.status !== 'pending'
})
// During streaming, exclude pending messages to prevent frequent minimap recalculations
const mapped = props.items
.filter((item) => {
if (!isStreaming.value) return true
return !item.message || item.message.status !== 'pending'
})
🤖 Prompt for AI Agents
In @src/renderer/src/components/message/MessageList.vue around lines 173 - 178,
Translate the Chinese comment above the mapped computation into English; replace
"如果正在 streaming,排除 pending 状态的消息,避免 minimap 频繁重新计算" with an English comment such
as "If streaming, exclude messages with pending status to avoid frequent minimap
recalculations" and keep surrounding code and symbols (mapped, props.items,
isStreaming, item.message.status === 'pending') unchanged.

.map((item) => {
if (item.message) return item.message
return {
id: item.id,
role: 'user',
conversationId: chatStore.getActiveThreadId() ?? '',
content: { text: '', files: [], links: [], think: false, search: false },
timestamp: Date.now()
} as unknown as Message
})
if (mapped.length > 0) return mapped
const current = chatStore.getCurrentThreadMessages()
if (current.length > 0) return current
Expand All @@ -191,6 +208,11 @@ const getMessageSizeKey = (item: MessageListItem) => {
const message = item.message
if (!message) return `placeholder:${item.id}`

// 如果正在 streaming,返回固定值,避免频繁重新计算高度
if (isStreaming.value && message.status === 'pending') {
return `streaming:${message.id}`
}
Comment on lines +211 to +214
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Chinese comment should be translated to English.

Per coding guidelines, all comments must be in English.

Suggested fix
-  // 如果正在 streaming,返回固定值,避免频繁重新计算高度
+  // During streaming, return a stable key to avoid frequent height recalculations
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 如果正在 streaming,返回固定值,避免频繁重新计算高度
if (isStreaming.value && message.status === 'pending') {
return `streaming:${message.id}`
}
// During streaming, return a stable key to avoid frequent height recalculations
if (isStreaming.value && message.status === 'pending') {
return `streaming:${message.id}`
}
🤖 Prompt for AI Agents
In @src/renderer/src/components/message/MessageList.vue around lines 211 - 214,
The inline Chinese comment above the streaming check in MessageList.vue should
be translated to English: replace "如果正在 streaming,返回固定值,避免频繁重新计算高度" with a
concise English comment such as "If currently streaming, return a fixed value to
avoid recalculating height frequently" immediately above the if block that
checks isStreaming.value and message.status === 'pending' (the block that
returns `streaming:${message.id}`) so the intent is clear to all readers.


if (message.role === 'assistant') {
const blocks = (message as AssistantMessage).content
if (Array.isArray(blocks)) {
Expand Down Expand Up @@ -219,6 +241,8 @@ const getMessageSizeKey = (item: MessageListItem) => {
const getVariantSizeKey = (item: MessageListItem) => {
const message = item.message
if (!message || message.role !== 'assistant') return ''
// 如果正在 streaming,不参与 variant 计算
if (isStreaming.value && message.status === 'pending') return ''
Comment on lines +244 to +245
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Chinese comment should be translated to English.

Per coding guidelines, all comments must be in English.

Suggested fix
-  // 如果正在 streaming,不参与 variant 计算
+  // During streaming, skip variant calculation for pending messages
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 如果正在 streaming,不参与 variant 计算
if (isStreaming.value && message.status === 'pending') return ''
// During streaming, skip variant calculation for pending messages
if (isStreaming.value && message.status === 'pending') return ''
🤖 Prompt for AI Agents
In @src/renderer/src/components/message/MessageList.vue around lines 244 - 245,
Translate the Chinese comment above the early-return in MessageList.vue to
English; replace "如果正在 streaming,不参与 variant 计算" with an English comment that
clearly conveys the same meaning (e.g., "If currently streaming, exclude from
variant calculation") and keep it adjacent to the if (isStreaming.value &&
message.status === 'pending') return '' line so it still documents that pending
streaming messages are not considered in variant computation.

return chatStore.selectedVariantsMap[message.id] ?? ''
}

Expand Down Expand Up @@ -523,6 +547,9 @@ const recordVisibleDomInfo = () => {
const container = messagesContainer.value
if (!container) return

// 如果正在 streaming,跳过 dom info 记录,避免频繁计算
if (isStreaming.value) return
Comment on lines +550 to +551
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Chinese comment should be translated to English.

Per coding guidelines, all comments must be in English.

Suggested fix
-  // 如果正在 streaming,跳过 dom info 记录,避免频繁计算
+  // During streaming, skip DOM info recording to reduce computation
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 如果正在 streaming,跳过 dom info 记录,避免频繁计算
if (isStreaming.value) return
// During streaming, skip DOM info recording to reduce computation
if (isStreaming.value) return
🤖 Prompt for AI Agents
In @src/renderer/src/components/message/MessageList.vue around lines 550 - 551,
Translate the Chinese inline comment above the isStreaming check into English
while preserving its meaning; replace "// 如果正在 streaming,跳过 dom info 记录,避免频繁计算"
with an English comment such as "// If currently streaming, skip DOM info
logging to avoid expensive/redundant calculations" immediately before the if
(isStreaming.value) return line in the MessageList component.


const containerRect = container.getBoundingClientRect()
const bufferZone = containerRect.height * BUFFER_ZONE_MULTIPLIER
const entries: Array<{ id: string; top: number; height: number }> = []
Expand Down