diff --git a/gui/src/components/modelSelection/ModeSelect.tsx b/gui/src/components/modelSelection/ModeSelect.tsx index 92395f545..3bb1c6f9b 100644 --- a/gui/src/components/modelSelection/ModeSelect.tsx +++ b/gui/src/components/modelSelection/ModeSelect.tsx @@ -8,9 +8,10 @@ import { } from "@heroicons/react/24/outline"; import { MessageModes } from "core"; import { modelSupportsTools } from "core/llm/autodetect"; -import { useEffect, useMemo } from "react"; +import { useEffect, useMemo, useState } from "react"; import styled from "styled-components"; import { lightGray } from ".."; +import { useWebviewListener } from "../../hooks/useWebviewListener"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { selectSelectedChatModel } from "../../redux/slices/configSlice"; import { @@ -41,6 +42,8 @@ function ModeSelect() { const dispatch = useAppDispatch(); const mode = useAppSelector(selectCurrentMode); const selectedModel = useAppSelector(selectSelectedChatModel); + const currentSession = useAppSelector((state) => state.session); + const [newChatSessionInitialized, setNewChatSessionInitialized] = useState(false); const agentModeSupported = selectedModel && modelSupportsTools(selectedModel); const jetbrains = useMemo(() => { @@ -83,6 +86,16 @@ function ModeSelect() { return () => document.removeEventListener("keydown", handleKeyDown); }, [dispatch, mode, jetbrains]); + useWebviewListener("newSession", async () => { + setNewChatSessionInitialized(true); + }); + + useEffect(() => { + if (currentSession.history.length > 0) { + setNewChatSessionInitialized(false); + } + }, [currentSession.history]); + return (