mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-23 20:26:15 +00:00
chore(log): remove console log
This commit is contained in:
parent
6d807783d5
commit
a7b655f15d
@ -73,7 +73,6 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
|
|
||||||
// Get prompt_code from localStorage
|
// Get prompt_code from localStorage
|
||||||
const storedPromptCode = localStorage.getItem(`dbgpt_prompt_code_${chatId}`);
|
const storedPromptCode = localStorage.getItem(`dbgpt_prompt_code_${chatId}`);
|
||||||
console.log('DEBUG - Completion - prompt_code from localStorage:', storedPromptCode);
|
|
||||||
|
|
||||||
// Create data object with prompt_code if available
|
// Create data object with prompt_code if available
|
||||||
const submitData: Record<string, any> = {
|
const submitData: Record<string, any> = {
|
||||||
@ -84,7 +83,6 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
// Add prompt_code if it exists
|
// Add prompt_code if it exists
|
||||||
if (storedPromptCode) {
|
if (storedPromptCode) {
|
||||||
submitData.prompt_code = storedPromptCode;
|
submitData.prompt_code = storedPromptCode;
|
||||||
console.log('DEBUG - Completion - adding prompt_code to submitData:', storedPromptCode);
|
|
||||||
|
|
||||||
// Clear prompt_code from localStorage after use
|
// Clear prompt_code from localStorage after use
|
||||||
localStorage.removeItem(`dbgpt_prompt_code_${chatId}`);
|
localStorage.removeItem(`dbgpt_prompt_code_${chatId}`);
|
||||||
@ -189,7 +187,6 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
|
|
||||||
// Initialize refs only once
|
// Initialize refs only once
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('Completion initializing refs');
|
|
||||||
// Initialize message count tracking
|
// Initialize message count tracking
|
||||||
if (prevMessageCountRef.current === 0) {
|
if (prevMessageCountRef.current === 0) {
|
||||||
prevMessageCountRef.current = 0; // Will be set when first message arrives
|
prevMessageCountRef.current = 0; // Will be set when first message arrives
|
||||||
@ -210,7 +207,6 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
|
|
||||||
// If user scrolled up during streaming, exit streaming mode to respect user intention
|
// If user scrolled up during streaming, exit streaming mode to respect user intention
|
||||||
if (isStreamingRef.current && !isAtBottom && wasUserScrolling !== isUserScrollingRef.current) {
|
if (isStreamingRef.current && !isAtBottom && wasUserScrolling !== isUserScrollingRef.current) {
|
||||||
console.log('User scrolled up during streaming, exiting streaming mode');
|
|
||||||
isStreamingRef.current = false;
|
isStreamingRef.current = false;
|
||||||
// Clear streaming timeout
|
// Clear streaming timeout
|
||||||
if (streamingTimeoutRef.current) {
|
if (streamingTimeoutRef.current) {
|
||||||
@ -218,17 +214,6 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
streamingTimeoutRef.current = null;
|
streamingTimeoutRef.current = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasUserScrolling !== isUserScrollingRef.current) {
|
|
||||||
console.log('User scroll state changed:', {
|
|
||||||
isAtBottom,
|
|
||||||
isUserScrolling: isUserScrollingRef.current,
|
|
||||||
scrollTop,
|
|
||||||
scrollHeight,
|
|
||||||
clientHeight,
|
|
||||||
wasStreaming: isStreamingRef.current,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -237,7 +222,6 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
if (!scrollableRef.current) return;
|
if (!scrollableRef.current) return;
|
||||||
|
|
||||||
const scrollElement = scrollableRef.current;
|
const scrollElement = scrollableRef.current;
|
||||||
console.log('Scrolling to bottom');
|
|
||||||
|
|
||||||
// Use instant scroll to avoid animation-related event conflicts
|
// Use instant scroll to avoid animation-related event conflicts
|
||||||
scrollElement.scrollTo({
|
scrollElement.scrollTo({
|
||||||
@ -253,24 +237,11 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
const currentMessageCount = showMessages.length;
|
const currentMessageCount = showMessages.length;
|
||||||
const isNewMessage = currentMessageCount > prevMessageCountRef.current;
|
const isNewMessage = currentMessageCount > prevMessageCountRef.current;
|
||||||
|
|
||||||
console.log('Completion scroll check:', {
|
|
||||||
currentMessageCount,
|
|
||||||
prevCount: prevMessageCountRef.current,
|
|
||||||
isNewMessage,
|
|
||||||
isStreaming: isStreamingRef.current,
|
|
||||||
isUserScrolling: isUserScrollingRef.current,
|
|
||||||
lastContentHeight: lastContentHeightRef.current,
|
|
||||||
currentScrollHeight: scrollElement.scrollHeight,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle new messages - always scroll to bottom and start streaming mode
|
// Handle new messages - always scroll to bottom and start streaming mode
|
||||||
if (isNewMessage) {
|
if (isNewMessage) {
|
||||||
console.log('Completion: New message detected, forcing restart of streaming mode');
|
|
||||||
|
|
||||||
// Force exit any existing streaming mode
|
// Force exit any existing streaming mode
|
||||||
if (streamingTimeoutRef.current) {
|
if (streamingTimeoutRef.current) {
|
||||||
clearTimeout(streamingTimeoutRef.current);
|
clearTimeout(streamingTimeoutRef.current);
|
||||||
console.log('Cleared existing streaming timeout');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enter streaming mode - disable user scroll detection
|
// Enter streaming mode - disable user scroll detection
|
||||||
@ -286,7 +257,6 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
|
|
||||||
// Exit streaming mode after no content updates for 3 seconds (increased timeout)
|
// Exit streaming mode after no content updates for 3 seconds (increased timeout)
|
||||||
streamingTimeoutRef.current = setTimeout(() => {
|
streamingTimeoutRef.current = setTimeout(() => {
|
||||||
console.log('Exiting streaming mode after timeout');
|
|
||||||
isStreamingRef.current = false;
|
isStreamingRef.current = false;
|
||||||
}, 3000); // Increased from 2000 to 3000
|
}, 3000); // Increased from 2000 to 3000
|
||||||
|
|
||||||
@ -297,32 +267,16 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
if (isStreamingRef.current) {
|
if (isStreamingRef.current) {
|
||||||
const currentHeight = scrollElement.scrollHeight;
|
const currentHeight = scrollElement.scrollHeight;
|
||||||
|
|
||||||
console.log('Completion streaming update:', {
|
|
||||||
currentHeight,
|
|
||||||
lastHeight: lastContentHeightRef.current,
|
|
||||||
isFirstCheck: lastContentHeightRef.current === 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize baseline height or check for changes
|
// Initialize baseline height or check for changes
|
||||||
if (lastContentHeightRef.current === 0) {
|
if (lastContentHeightRef.current === 0) {
|
||||||
console.log('Setting initial baseline height:', currentHeight);
|
|
||||||
lastContentHeightRef.current = currentHeight;
|
lastContentHeightRef.current = currentHeight;
|
||||||
// Don't return here - continue to check for immediate height differences
|
// Don't return here - continue to check for immediate height differences
|
||||||
}
|
}
|
||||||
|
|
||||||
const heightDiff = currentHeight - lastContentHeightRef.current;
|
const heightDiff = currentHeight - lastContentHeightRef.current;
|
||||||
|
|
||||||
console.log('Completion streaming height check:', {
|
|
||||||
currentHeight,
|
|
||||||
lastHeight: lastContentHeightRef.current,
|
|
||||||
heightDiff,
|
|
||||||
willScroll: heightDiff > 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Any height increase triggers scroll during streaming
|
// Any height increase triggers scroll during streaming
|
||||||
if (heightDiff > 0) {
|
if (heightDiff > 0) {
|
||||||
console.log('Completion: Content height increased by', heightDiff, 'px, scrolling');
|
|
||||||
|
|
||||||
// Scroll immediately
|
// Scroll immediately
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
|
|
||||||
@ -334,11 +288,8 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
clearTimeout(streamingTimeoutRef.current);
|
clearTimeout(streamingTimeoutRef.current);
|
||||||
}
|
}
|
||||||
streamingTimeoutRef.current = setTimeout(() => {
|
streamingTimeoutRef.current = setTimeout(() => {
|
||||||
console.log('Exiting streaming mode after content timeout');
|
|
||||||
isStreamingRef.current = false;
|
isStreamingRef.current = false;
|
||||||
}, 3000);
|
}, 3000);
|
||||||
} else if (heightDiff === 0) {
|
|
||||||
console.log('Completion: No height change during streaming, content may not be updating');
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Not streaming - check if user wants auto-scroll
|
// Not streaming - check if user wants auto-scroll
|
||||||
@ -347,12 +298,9 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
|
|||||||
const heightDiff = currentHeight - lastContentHeightRef.current;
|
const heightDiff = currentHeight - lastContentHeightRef.current;
|
||||||
|
|
||||||
if (heightDiff > 0) {
|
if (heightDiff > 0) {
|
||||||
console.log('Completion: Non-streaming height increase, scrolling');
|
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
lastContentHeightRef.current = currentHeight;
|
lastContentHeightRef.current = currentHeight;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log('Completion: User has scrolled away, not auto-scrolling');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [showMessages, scene, scrollToBottom]);
|
}, [showMessages, scene, scrollToBottom]);
|
||||||
|
@ -406,19 +406,15 @@ const Chat: React.FC = () => {
|
|||||||
{/* Render PromptBot at the bottom right */}
|
{/* Render PromptBot at the bottom right */}
|
||||||
<PromptBot
|
<PromptBot
|
||||||
submit={prompt => {
|
submit={prompt => {
|
||||||
console.log('Selected prompt:', prompt);
|
|
||||||
|
|
||||||
// For chat_dashboard, only store prompt_code in localStorage
|
// For chat_dashboard, only store prompt_code in localStorage
|
||||||
// The input filling will be handled by the CompletionInput's PromptBot
|
// The input filling will be handled by the CompletionInput's PromptBot
|
||||||
if (scene === 'chat_dashboard') {
|
if (scene === 'chat_dashboard') {
|
||||||
localStorage.setItem(`dbgpt_prompt_code_${chatId}`, prompt.prompt_code);
|
localStorage.setItem(`dbgpt_prompt_code_${chatId}`, prompt.prompt_code);
|
||||||
console.log('Stored prompt_code for chat_dashboard:', prompt.prompt_code);
|
|
||||||
} else {
|
} else {
|
||||||
// For other scenes, fill input and store prompt_code
|
// For other scenes, fill input and store prompt_code
|
||||||
chatInputRef.current?.setUserInput?.(prompt.content);
|
chatInputRef.current?.setUserInput?.(prompt.content);
|
||||||
selectedPromptCodeRef.current = prompt.prompt_code;
|
selectedPromptCodeRef.current = prompt.prompt_code;
|
||||||
localStorage.setItem(`dbgpt_prompt_code_${chatId}`, prompt.prompt_code);
|
localStorage.setItem(`dbgpt_prompt_code_${chatId}`, prompt.prompt_code);
|
||||||
console.log('Filled input and stored prompt_code:', prompt.prompt_code);
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
chat_scene={scene}
|
chat_scene={scene}
|
||||||
|
Loading…
Reference in New Issue
Block a user