fix(admin): Fix Prompt management list not showing version info and add debug diagnostics
Summary: - Fix Prompt list API response schema missing activeVersion and draftVersion fields - Fastify was filtering out undefined schema fields, causing version columns to show empty - Add detailed diagnostic logging for Prompt debug mode troubleshooting - Verify debug mode works correctly (DRAFT version is used when debug enabled) Changes: - backend/src/common/prompt/prompt.routes.ts: Add activeVersion and draftVersion to response schema - backend/src/common/prompt/prompt.service.ts: Add diagnostic logs for setDebugMode and get methods - PKB module: Various authentication and document handling fixes from previous session Tested: Debug mode verified working - v2 DRAFT version correctly loaded when debug enabled
This commit is contained in:
@@ -18,7 +18,7 @@ import './styles/chat.css';
|
||||
* ChatContainer 组件(简化实现)
|
||||
*/
|
||||
export const ChatContainer: React.FC<ChatContainerProps> = ({
|
||||
conversationKey: _conversationKey,
|
||||
conversationKey,
|
||||
defaultMessages = [],
|
||||
providerConfig,
|
||||
customMessageRenderer,
|
||||
@@ -29,8 +29,8 @@ export const ChatContainer: React.FC<ChatContainerProps> = ({
|
||||
className = '',
|
||||
style = {},
|
||||
}) => {
|
||||
// 如果没有默认消息,添加欢迎语
|
||||
const initialMessages = defaultMessages.length > 0 ? defaultMessages : [{
|
||||
// 默认欢迎语
|
||||
const defaultWelcome: ChatMessage[] = [{
|
||||
id: 'welcome',
|
||||
role: 'assistant' as const,
|
||||
content: '您好!我是您的 AI 数据分析师。我可以帮您编写代码来清洗数据。试试说:"把年龄大于60的设为老年组"。',
|
||||
@@ -38,11 +38,27 @@ export const ChatContainer: React.FC<ChatContainerProps> = ({
|
||||
timestamp: Date.now(),
|
||||
}];
|
||||
|
||||
const [messages, setMessages] = useState<ChatMessage[]>(initialMessages);
|
||||
const [messages, setMessages] = useState<ChatMessage[]>(
|
||||
defaultMessages.length > 0 ? defaultMessages : defaultWelcome
|
||||
);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [inputValue, setInputValue] = useState(''); // 受控输入框
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null); // 用于滚动到底部
|
||||
|
||||
// 🔑 当 conversationKey 变化时,重置消息状态
|
||||
// 使用 ref 记录上一次的 key,避免初始化时重复设置
|
||||
const prevKeyRef = useRef(conversationKey);
|
||||
useEffect(() => {
|
||||
if (prevKeyRef.current !== conversationKey) {
|
||||
console.log('[ChatContainer] conversationKey 变化,重置消息:', conversationKey);
|
||||
const newMessages = defaultMessages.length > 0 ? defaultMessages : defaultWelcome;
|
||||
setMessages(newMessages);
|
||||
setInputValue('');
|
||||
setIsLoading(false);
|
||||
prevKeyRef.current = conversationKey;
|
||||
}
|
||||
}, [conversationKey, defaultMessages]);
|
||||
|
||||
// 滚动到底部
|
||||
const scrollToBottom = useCallback(() => {
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -57,6 +57,8 @@ export { default as Placeholder } from './Placeholder';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user