diff --git a/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx b/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx index ebef0251b..9d8c79ccc 100644 --- a/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx +++ b/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx @@ -9,11 +9,10 @@ import { WrenchScrewdriverIcon, } from "@heroicons/react/24/outline"; import { vscBadgeBackground, vscBadgeForeground } from "../.."; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; -import { toggleBlockSettingsToolbar } from "../../../redux/slices/uiSlice"; import { fontSize } from "../../../util"; import AssistantSelect from "../../modelSelection/platform/AssistantSelect"; import HoverItem from "../InputToolbar/HoverItem"; +import { useLump } from "./LumpContext"; interface BlockSettingsToolbarIcon { tooltip: string; @@ -87,15 +86,13 @@ interface BlockSettingsTopToolbarProps { } export function BlockSettingsTopToolbar(props: BlockSettingsTopToolbarProps) { - const isExpanded = useAppSelector( - (state) => state.ui.isBlockSettingsToolbarExpanded, - ); - const dispatch = useAppDispatch(); + const { isToolbarExpanded, toggleToolbar } = useLump(); + const handleEllipsisClick = () => { - if (isExpanded) { + if (isToolbarExpanded) { props.setSelectedSection(null); } - dispatch(toggleBlockSettingsToolbar()); + toggleToolbar(); }; return ( @@ -103,14 +100,14 @@ export function BlockSettingsTopToolbar(props: BlockSettingsTopToolbarProps) {
{sections.map((section) => ( diff --git a/gui/src/components/mainInput/Lump/LumpContext.tsx b/gui/src/components/mainInput/Lump/LumpContext.tsx index 4e93777ea..8b6417f6f 100644 --- a/gui/src/components/mainInput/Lump/LumpContext.tsx +++ b/gui/src/components/mainInput/Lump/LumpContext.tsx @@ -6,8 +6,10 @@ import { createContext, ReactNode, useContext } from "react"; interface LumpContextType { isLumpVisible: boolean; selectedSection: string | null; + isToolbarExpanded: boolean; hideLump: () => void; setSelectedSection: (section: string | null) => void; + toggleToolbar: () => void; } const LumpContext = createContext(undefined); @@ -16,8 +18,10 @@ interface LumpProviderProps { children: ReactNode; isLumpVisible: boolean; selectedSection: string | null; + isToolbarExpanded: boolean; hideLump: () => void; setSelectedSection: (section: string | null) => void; + toggleToolbar: () => void; } /** @@ -27,12 +31,21 @@ export function LumpProvider({ children, isLumpVisible, selectedSection, + isToolbarExpanded, hideLump, setSelectedSection, + toggleToolbar, }: LumpProviderProps) { return ( {children} diff --git a/gui/src/components/mainInput/Lump/index.tsx b/gui/src/components/mainInput/Lump/index.tsx index df1875c86..b9df37108 100644 --- a/gui/src/components/mainInput/Lump/index.tsx +++ b/gui/src/components/mainInput/Lump/index.tsx @@ -38,6 +38,7 @@ export function Lump() { const [selectedSection, setSelectedSection] = useState(null); const [displayedSection, setDisplayedSection] = useState(null); const [isVisible, setIsVisible] = useState(false); + const [isToolbarExpanded, setIsToolbarExpanded] = useState(true); const isStreaming = useAppSelector((state) => state.session.isStreaming); // Handle keyboard escape @@ -55,6 +56,11 @@ export function Lump() { setSelectedSection(null); }, []); + // Function to toggle toolbar expanded state + const toggleToolbar = useCallback(() => { + setIsToolbarExpanded((prev) => !prev); + }, []); + // Reset when streaming starts if (isStreaming && selectedSection) { setSelectedSection(null); @@ -84,8 +90,10 @@ export function Lump() {
diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx index 36495145d..2c8fc2d68 100644 --- a/gui/src/components/modelSelection/platform/AssistantSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx @@ -11,7 +11,7 @@ import { useContext, useEffect, useMemo, useRef } from "react"; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { cycleProfile, selectProfileThunk } from "../../../redux"; -import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { useAppDispatch } from "../../../redux/hooks"; import { fontSize, getMetaKeyLabel, @@ -31,6 +31,7 @@ import { useNavigate } from "react-router-dom"; import { vscCommandCenterInactiveBorder } from "../.."; import { ROUTES } from "../../../util/navigation"; import { ToolTip } from "../../gui/Tooltip"; +import { useLump } from "../../mainInput/Lump/LumpContext"; import { useFontSize } from "../../ui/font"; import AssistantIcon from "./AssistantIcon"; @@ -143,9 +144,7 @@ export default function AssistantSelect() { const buttonRef = useRef(null); const { selectedProfile, selectedOrganization } = useAuth(); const ideMessenger = useContext(IdeMessengerContext); - const isLumpToolbarExpanded = useAppSelector( - (state) => state.ui.isBlockSettingsToolbarExpanded, - ); + const { isToolbarExpanded } = useLump(); const { profiles, session, login } = useAuth(); const navigate = useNavigate(); @@ -205,7 +204,7 @@ export default function AssistantSelect() { > Create your first assistant @@ -227,7 +226,7 @@ export default function AssistantSelect() {
{selectedProfile.title} diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 7bb7fb3fd..13efdfa1a 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -25,7 +25,6 @@ type UIState = { toolSettings: { [toolName: string]: ToolSetting }; toolGroupSettings: { [toolGroupName: string]: ToolGroupSetting }; ttsActive: boolean; - isBlockSettingsToolbarExpanded: boolean; }; export const DEFAULT_TOOL_SETTING: ToolSetting = "allowedWithPermission"; @@ -56,7 +55,6 @@ export const uiSlice = createSlice({ toolGroupSettings: { BUILT_IN_GROUP_NAME: "include", }, - isBlockSettingsToolbarExpanded: true, } as UIState, reducers: { setOnboardingCard: ( @@ -124,10 +122,6 @@ export const uiSlice = createSlice({ setTTSActive: (state, { payload }: PayloadAction) => { state.ttsActive = payload; }, - toggleBlockSettingsToolbar: (state) => { - state.isBlockSettingsToolbarExpanded = - !state.isBlockSettingsToolbarExpanded; - }, }, }); @@ -142,7 +136,6 @@ export const { toggleToolGroupSetting, addTool, setTTSActive, - toggleBlockSettingsToolbar, } = uiSlice.actions; export default uiSlice.reducer;