mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-21 07:40:11 +08:00
Add initial chunk emission for agent response processing
- Emit `ChunkType.LLM_RESPONSE_CREATED` event to mirror assistant behavior - Ensure UI reflects pending state immediately during response processing - Maintain consistency with existing stream processing callback structure
This commit is contained in:
parent
d960a42d6e
commit
86a2780e2c
@ -11,6 +11,7 @@ import store from '@renderer/store'
|
|||||||
import { updateTopicUpdatedAt } from '@renderer/store/assistants'
|
import { updateTopicUpdatedAt } from '@renderer/store/assistants'
|
||||||
import { type ApiServerConfig, type Assistant, type FileMetadata, type Model, type Topic } from '@renderer/types'
|
import { type ApiServerConfig, type Assistant, type FileMetadata, type Model, type Topic } from '@renderer/types'
|
||||||
import type { AgentPersistedMessage } from '@renderer/types/agent'
|
import type { AgentPersistedMessage } from '@renderer/types/agent'
|
||||||
|
import { ChunkType } from '@renderer/types/chunk'
|
||||||
import type { FileMessageBlock, ImageMessageBlock, Message, MessageBlock } from '@renderer/types/newMessage'
|
import type { FileMessageBlock, ImageMessageBlock, Message, MessageBlock } from '@renderer/types/newMessage'
|
||||||
import { AssistantMessageStatus, MessageBlockStatus, MessageBlockType } from '@renderer/types/newMessage'
|
import { AssistantMessageStatus, MessageBlockStatus, MessageBlockType } from '@renderer/types/newMessage'
|
||||||
import { uuid } from '@renderer/utils'
|
import { uuid } from '@renderer/utils'
|
||||||
@ -442,6 +443,9 @@ const fetchAndProcessAgentResponseImpl = async (
|
|||||||
|
|
||||||
const streamProcessorCallbacks = createStreamProcessor(callbacks)
|
const streamProcessorCallbacks = createStreamProcessor(callbacks)
|
||||||
|
|
||||||
|
// Emit initial chunk to mirror assistant behaviour and ensure pending UI state
|
||||||
|
streamProcessorCallbacks({ type: ChunkType.LLM_RESPONSE_CREATED })
|
||||||
|
|
||||||
const state = getState()
|
const state = getState()
|
||||||
const userMessageEntity = state.messages.entities[userMessageId]
|
const userMessageEntity = state.messages.entities[userMessageId]
|
||||||
const userContent = userMessageEntity ? getMainTextContent(userMessageEntity) : ''
|
const userContent = userMessageEntity ? getMainTextContent(userMessageEntity) : ''
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user