feat(chat): show revert button on all user messages
Remove restriction preventing revert on first user message Simplify message props by removing isFirstMessage flag
This commit is contained in:
@@ -133,7 +133,6 @@ interface MessageBodyProps {
|
||||
agentMention?: AgentMentionInfo;
|
||||
turnGroupingContext?: TurnGroupingContext;
|
||||
onRevert?: () => void;
|
||||
isFirstMessage?: boolean;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
@@ -148,8 +147,7 @@ const UserMessageBody: React.FC<{
|
||||
onShowPopup: (content: ToolPopupContent) => void;
|
||||
agentMention?: AgentMentionInfo;
|
||||
onRevert?: () => void;
|
||||
isFirstMessage?: boolean;
|
||||
}> = ({ messageId, parts, isMobile, hasTouchInput, hasTextContent, onCopyMessage, copiedMessage, onShowPopup, agentMention, onRevert, isFirstMessage }) => {
|
||||
}> = ({ messageId, parts, isMobile, hasTouchInput, hasTextContent, onCopyMessage, copiedMessage, onShowPopup, agentMention, onRevert }) => {
|
||||
const [copyHintVisible, setCopyHintVisible] = React.useState(false);
|
||||
const copyHintTimeoutRef = React.useRef<number | null>(null);
|
||||
|
||||
@@ -241,12 +239,12 @@ const UserMessageBody: React.FC<{
|
||||
})}
|
||||
</div>
|
||||
<MessageFilesDisplay files={parts} onShowPopup={onShowPopup} />
|
||||
{(canCopyMessage && hasCopyableText) || (onRevert && !isFirstMessage) ? (
|
||||
{(canCopyMessage && hasCopyableText) || onRevert ? (
|
||||
<div className={cn(
|
||||
"mt-1 flex items-center justify-end gap-2 opacity-0 pointer-events-none transition-opacity duration-150 group-hover/message:opacity-100 group-hover/message:pointer-events-auto focus-within:opacity-100 focus-within:pointer-events-auto",
|
||||
copyHintVisible && "opacity-100 pointer-events-auto"
|
||||
)}>
|
||||
{onRevert && !isFirstMessage && (
|
||||
{onRevert && (
|
||||
<Tooltip delayDuration={1000}>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
@@ -1228,7 +1226,6 @@ const MessageBody: React.FC<MessageBodyProps> = ({ isUser, ...props }) => {
|
||||
onShowPopup={props.onShowPopup}
|
||||
agentMention={props.agentMention}
|
||||
onRevert={props.onRevert}
|
||||
isFirstMessage={props.isFirstMessage}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user