mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 14:59:27 +08:00
fix: add message processing status check to Message component (#9982)
This commit is contained in:
parent
cb4b26c8a4
commit
ff74e9035d
@ -14,6 +14,7 @@ import { estimateMessageUsage } from '@renderer/services/TokenService'
|
|||||||
import { Assistant, Topic } from '@renderer/types'
|
import { Assistant, Topic } from '@renderer/types'
|
||||||
import type { Message, MessageBlock } from '@renderer/types/newMessage'
|
import type { Message, MessageBlock } from '@renderer/types/newMessage'
|
||||||
import { classNames } from '@renderer/utils'
|
import { classNames } from '@renderer/utils'
|
||||||
|
import { isMessageProcessing } from '@renderer/utils/messageUtils/is'
|
||||||
import { Divider } from 'antd'
|
import { Divider } from 'antd'
|
||||||
import React, { Dispatch, FC, memo, SetStateAction, useCallback, useEffect, useRef } from 'react'
|
import React, { Dispatch, FC, memo, SetStateAction, useCallback, useEffect, useRef } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
@ -115,7 +116,8 @@ const MessageItem: FC<Props> = ({
|
|||||||
|
|
||||||
const isLastMessage = index === 0 || !!isGrouped
|
const isLastMessage = index === 0 || !!isGrouped
|
||||||
const isAssistantMessage = message.role === 'assistant'
|
const isAssistantMessage = message.role === 'assistant'
|
||||||
const showMenubar = !hideMenuBar && !isEditing
|
const isProcessing = isMessageProcessing(message)
|
||||||
|
const showMenubar = !hideMenuBar && !isEditing && !isProcessing
|
||||||
|
|
||||||
const messageHighlightHandler = useCallback(
|
const messageHighlightHandler = useCallback(
|
||||||
(highlight: boolean = true) => {
|
(highlight: boolean = true) => {
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import {
|
import {
|
||||||
|
AssistantMessageStatus,
|
||||||
type CitationMessageBlock,
|
type CitationMessageBlock,
|
||||||
type CodeMessageBlock,
|
type CodeMessageBlock,
|
||||||
type ErrorMessageBlock,
|
type ErrorMessageBlock,
|
||||||
type FileMessageBlock,
|
type FileMessageBlock,
|
||||||
type ImageMessageBlock,
|
type ImageMessageBlock,
|
||||||
type MainTextMessageBlock,
|
type MainTextMessageBlock,
|
||||||
|
Message,
|
||||||
type MessageBlock,
|
type MessageBlock,
|
||||||
MessageBlockType,
|
MessageBlockType,
|
||||||
type PlaceholderMessageBlock,
|
type PlaceholderMessageBlock,
|
||||||
@ -147,3 +149,11 @@ export function isCitationBlock(block: MessageBlock): block is CitationMessageBl
|
|||||||
export function isPlaceholderBlock(block: MessageBlock): block is PlaceholderMessageBlock {
|
export function isPlaceholderBlock(block: MessageBlock): block is PlaceholderMessageBlock {
|
||||||
return block.type === MessageBlockType.UNKNOWN
|
return block.type === MessageBlockType.UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isMessageProcessing(message: Message): boolean {
|
||||||
|
return (
|
||||||
|
message.status === AssistantMessageStatus.PROCESSING ||
|
||||||
|
message.status === AssistantMessageStatus.PENDING ||
|
||||||
|
message.status === AssistantMessageStatus.SEARCHING
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user