fix: insert reasoning block before the content block (#10545)

fix: always insert reasoning block before the content block
This commit is contained in:
Tristan Zhang 2025-10-09 22:32:13 +08:00 committed by GitHub
parent 89bb830b60
commit 73b2a375ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View File

@ -121,7 +121,8 @@ export class BlockManager {
newMessagesActions.upsertBlockReference({
messageId: this.deps.assistantMsgId,
blockId: newBlock.id,
status: newBlock.status
status: newBlock.status,
blockType: newBlock.type
})
)

View File

@ -2,7 +2,7 @@ import { loggerService } from '@logger'
import { createEntityAdapter, createSlice, EntityState, PayloadAction } from '@reduxjs/toolkit'
// Separate type-only imports from value imports
import type { Message } from '@renderer/types/newMessage'
import { AssistantMessageStatus, MessageBlockStatus } from '@renderer/types/newMessage'
import { AssistantMessageStatus, MessageBlockStatus, MessageBlockType } from '@renderer/types/newMessage'
const logger = loggerService.withContext('newMessage')
@ -50,6 +50,7 @@ interface UpsertBlockReferencePayload {
messageId: string
blockId: string
status?: MessageBlockStatus
blockType?: MessageBlockType
}
// Payload for removing a single message
@ -218,7 +219,7 @@ export const messagesSlice = createSlice({
messagesAdapter.removeMany(state, messageIds)
},
upsertBlockReference(state, action: PayloadAction<UpsertBlockReferencePayload>) {
const { messageId, blockId, status } = action.payload
const { messageId, blockId, status, blockType } = action.payload
const messageToUpdate = state.entities[messageId]
if (!messageToUpdate) {
@ -231,8 +232,12 @@ export const messagesSlice = createSlice({
// Update Block ID
const currentBlocks = messageToUpdate.blocks || []
if (!currentBlocks.includes(blockId)) {
if (blockType === MessageBlockType.THINKING) {
changes.blocks = [blockId, ...currentBlocks]
} else {
changes.blocks = [...currentBlocks, blockId]
}
}
// Update Message Status based on Block Status
if (status) {