From eeb9fe9b7f89e1490739684d1e5371afedb564e5 Mon Sep 17 00:00:00 2001 From: "Apple\\Apple" Date: Fri, 30 May 2025 21:34:13 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20enhance=20debug=20panel=20w?= =?UTF-8?q?ith=20real-time=20preview=20and=20collapsible=20tabs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add real-time request body preview that updates when parameters change - Implement pre-constructed payload generation for debugging without sending requests - Add support for image URLs in preview payload construction - Upgrade debug panel to card-style tabs with custom arrow navigation - Add collapsible functionality and dropdown menu for tab selection - Integrate image-enabled messages with proper multimodal content structure - Refactor tab state management with internal useState and external sync - Remove redundant status labels and clean up component structure - Set preview tab as default active tab for better UX - Maintain backward compatibility with existing debug functionality This enhancement significantly improves the debugging experience by allowing developers to see exactly what request will be sent before actually sending it, with real-time updates as they adjust parameters, models, or image settings. --- web/src/components/playground/DebugPanel.js | 123 +++++++++++++--- .../components/playground/ImageUrlInput.js | 3 - .../components/playground/SettingsPanel.js | 2 +- web/src/pages/Playground/Playground.js | 138 +++++++++++++++++- 4 files changed, 242 insertions(+), 24 deletions(-) diff --git a/web/src/components/playground/DebugPanel.js b/web/src/components/playground/DebugPanel.js index 935bd681..8487d555 100644 --- a/web/src/components/playground/DebugPanel.js +++ b/web/src/components/playground/DebugPanel.js @@ -1,17 +1,19 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import { Card, Typography, Tabs, TabPane, Button, + Dropdown, } from '@douyinfe/semi-ui'; import { Code, - FileText, Zap, Clock, X, + Eye, + Send, } from 'lucide-react'; import { useTranslation } from 'react-i18next'; @@ -24,6 +26,61 @@ const DebugPanel = ({ }) => { const { t } = useTranslation(); + const [activeKey, setActiveKey] = useState(activeDebugTab); + + useEffect(() => { + setActiveKey(activeDebugTab); + }, [activeDebugTab]); + + const handleTabChange = (key) => { + setActiveKey(key); + onActiveDebugTabChange(key); + }; + + const renderArrow = (items, pos, handleArrowClick, defaultNode) => { + const style = { + width: 32, + height: 32, + margin: '0 12px', + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + borderRadius: '100%', + background: 'rgba(var(--semi-grey-1), 1)', + color: 'var(--semi-color-text)', + cursor: 'pointer', + }; + + return ( + + {items.map(item => { + return ( + handleTabChange(item.itemKey)} + > + {item.tab} + + ); + })} + + } + > + {pos === 'start' ? ( +
+ ← +
+ ) : ( +
+ → +
+ )} +
+ ); + }; + return ( - {/* 移动端关闭按钮 */} {styleState.isMobile && onCloseDebugPanel && (