修复会话记录可能存储两次的bug;更改会话行为,默认进入新对话
This commit is contained in:
@@ -32,6 +32,7 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
|
||||
|
||||
const bottomRef = useRef<HTMLDivElement>(null);
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
const hasResetForOpenRef = useRef(false);
|
||||
const theme = useTheme();
|
||||
const currentProjectId = useProjectStore((state) => state.currentProjectId);
|
||||
|
||||
@@ -87,13 +88,22 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
|
||||
}, [messages, isStreaming]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
if (!open) {
|
||||
hasResetForOpenRef.current = false;
|
||||
return;
|
||||
}
|
||||
if (hasResetForOpenRef.current || isHydrating) return;
|
||||
hasResetForOpenRef.current = true;
|
||||
|
||||
const timer = window.setTimeout(() => {
|
||||
createSession();
|
||||
setInput("");
|
||||
setIsHistoryOpen(false);
|
||||
inputRef.current?.focus();
|
||||
bottomRef.current?.scrollIntoView({ behavior: "auto" });
|
||||
}, 0);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [open]);
|
||||
}, [createSession, isHydrating, open]);
|
||||
|
||||
const handleSend = useCallback(() => {
|
||||
const prompt = input.trim();
|
||||
@@ -112,7 +122,7 @@ export const GlobalChatbox: React.FC<Props> = ({ open, onClose }) => {
|
||||
const handleNewConversation = useCallback(() => {
|
||||
handleStopSpeech();
|
||||
stopListening();
|
||||
void createSession();
|
||||
createSession();
|
||||
setInput("");
|
||||
window.setTimeout(() => {
|
||||
inputRef.current?.focus();
|
||||
|
||||
Reference in New Issue
Block a user