修复会话记录可能存储两次的bug;更改会话行为,默认进入新对话
Build Push and Deploy / docker-image (push) Successful in 1m1s
Build Push and Deploy / deploy-fallback-log (push) Has been skipped

This commit is contained in:
2026-05-22 14:19:14 +08:00
parent 54fbf15be8
commit 6b447eb398
5 changed files with 103 additions and 163 deletions
+13 -3
View File
@@ -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();