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