From 0a848c2d6cdf72db0357ee6c80a7eda915e024b9 Mon Sep 17 00:00:00 2001 From: "Apple\\Apple" Date: Fri, 30 May 2025 21:51:09 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(playground):=20add=20role=20to?= =?UTF-8?q?ggle=20feature=20for=20AI=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add role toggle button in MessageActions component for assistant/system messages - Implement handleRoleToggle function in Playground component to switch between assistant and system roles - Add visual distinction for system messages with orange badge indicator - Update roleInfo configuration to use consistent avatars for assistant and system roles - Add proper tooltip texts and visual feedback for role switching - Ensure role toggle is disabled during message generation to prevent conflicts This feature allows users to easily switch message roles between assistant and system, providing better control over conversation flow and message categorization in the playground interface. --- .../components/playground/MessageActions.js | 37 ++++++++++++++++++- .../components/playground/MessageContent.js | 14 +++++++ web/src/pages/Playground/Playground.js | 23 ++++++++++-- 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/web/src/components/playground/MessageActions.js b/web/src/components/playground/MessageActions.js index 7ad2b529..7156a8ce 100644 --- a/web/src/components/playground/MessageActions.js +++ b/web/src/components/playground/MessageActions.js @@ -7,15 +7,24 @@ import { RefreshCw, Copy, Trash2, + UserCheck, } from 'lucide-react'; import { useTranslation } from 'react-i18next'; -const MessageActions = ({ message, styleState, onMessageReset, onMessageCopy, onMessageDelete, isAnyMessageGenerating = false }) => { +const MessageActions = ({ + message, + styleState, + onMessageReset, + onMessageCopy, + onMessageDelete, + onRoleToggle, + isAnyMessageGenerating = false +}) => { const { t } = useTranslation(); const isLoading = message.status === 'loading' || message.status === 'incomplete'; - const shouldDisableActions = isAnyMessageGenerating; + const canToggleRole = message.role === 'assistant' || message.role === 'system'; return (
@@ -48,6 +57,30 @@ const MessageActions = ({ message, styleState, onMessageReset, onMessageCopy, on )} + {canToggleRole && !isLoading && ( + +