fix: ghost session cleanup, new chat switching, and markdown overflow handling (#287)

This commit is contained in:
DigHuang
2026-03-04 18:54:47 +08:00
committed by GitHub
Unverified
parent 89028756e1
commit 76df84e68c
3 changed files with 37 additions and 7 deletions

View File

@@ -35,6 +35,8 @@ export function Chat() {
const abortRun = useChatStore((s) => s.abortRun);
const clearError = useChatStore((s) => s.clearError);
const cleanupEmptySession = useChatStore((s) => s.cleanupEmptySession);
const messagesEndRef = useRef<HTMLDivElement>(null);
const [streamingTimestamp, setStreamingTimestamp] = useState<number>(0);
@@ -54,8 +56,11 @@ export function Chat() {
})();
return () => {
cancelled = true;
// If the user navigates away without sending any messages, remove the
// empty session so it doesn't linger as a ghost entry in the sidebar.
cleanupEmptySession();
};
}, [isGatewayRunning, loadHistory, loadSessions]);
}, [isGatewayRunning, loadHistory, loadSessions, cleanupEmptySession]);
// Auto-scroll on new messages, streaming, or activity changes
useEffect(() => {