mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 02:20:10 +08:00
fix: insert reasoning block before the content block (#10545)
fix: always insert reasoning block before the content block
This commit is contained in:
parent
89bb830b60
commit
73b2a375ad
@ -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
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user