diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index ac269b9..993ee51 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -23,7 +23,7 @@ import { Snack, SeverityType } from './Snack'; import { VectorVisualizer } from './VectorVisualizer'; import { Controls } from './Controls'; import { Conversation, ConversationHandle } from './Conversation'; -import { useAutoScrollToBottom } from './AutoScroll'; +import { Scrollable } from './AutoScroll'; import './App.css'; import './Conversation.css'; @@ -81,7 +81,6 @@ const App = () => { const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down('md')); const snackRef = useRef(null); - const scrollRef = useAutoScrollToBottom(); useEffect(() => { if (prevIsDesktopRef.current === isDesktop) @@ -302,17 +301,11 @@ const App = () => { ]; return [ - { defaultPrompts: chatQuestions }} /> - , + , { display: "flex", flexGrow: 1 }} {...{ setSnack, connectionBase, sessionId }} />, - - , + , @@ -360,7 +347,7 @@ const App = () => { } ]; - }, [about, connectionBase, sessionId, setSnack, isMobile, scrollRef]); + }, [about, connectionBase, sessionId, setSnack, isMobile]); /* toolbar height is 64px + 8px margin-top */ diff --git a/frontend/src/AutoScroll.tsx b/frontend/src/AutoScroll.tsx index f81f741..d7e4c56 100644 --- a/frontend/src/AutoScroll.tsx +++ b/frontend/src/AutoScroll.tsx @@ -1,4 +1,6 @@ import { useEffect, useRef, useState, RefObject } from 'react'; +import Box from '@mui/material/Box'; +import { SxProps, Theme } from '@mui/material'; /** * Hook that automatically scrolls a container to the bottom when content changes @@ -13,7 +15,6 @@ const useAutoScrollToBottom = ( smooth: boolean = true ): RefObject => { const containerRef = useRef(null); - const [isUserScrollingUp, setIsUserScrollingUp] = useState(false); const lastScrollTop = useRef(0); const scrollTimeout = useRef(null); @@ -24,7 +25,8 @@ const useAutoScrollToBottom = ( return; } const lastScrollHeight = container.scrollHeight; - + var isUserScrollingUp = false; + // Function to check if we should scroll to bottom const checkAndScrollToBottom = (priorScrollHeight?: number | undefined): void => { if (!container) return; @@ -36,30 +38,30 @@ const useAutoScrollToBottom = ( scrollHeight - container.scrollTop - container.clientHeight <= container.clientHeight * threshold; if (isNearBottom && !isUserScrollingUp) { - console.log('Scrolling', { - isNearBottom, - isUserScrollingUp, - scrollHeightToUser: scrollHeight, - scrollHeight: container.scrollHeight, - scrollTop: container.scrollTop, - clientHeight: container.clientHeight, - threshold, - delta: container.scrollHeight - container.scrollTop - container.clientHeight - }); + // console.log('Scrolling', { + // isNearBottom, + // isUserScrollingUp, + // scrollHeightToUser: scrollHeight, + // scrollHeight: container.scrollHeight, + // scrollTop: container.scrollTop, + // clientHeight: container.clientHeight, + // threshold, + // delta: container.scrollHeight - container.scrollTop - container.clientHeight + // }); container.scrollTo({ top: container.scrollHeight, behavior: smooth ? 'smooth' : 'auto' }); } else { - console.log('Not scrolling', { - isNearBottom, - isUserScrollingUp, - scrollHeight: container.scrollHeight, - scrollTop: container.scrollTop, - clientHeight: container.clientHeight, - threshold, - delta: container.scrollHeight - container.scrollTop - container.clientHeight - }); + // console.log('Not scrolling', { + // isNearBottom, + // isUserScrollingUp, + // scrollHeight: container.scrollHeight, + // scrollTop: container.scrollTop, + // clientHeight: container.clientHeight, + // threshold, + // delta: container.scrollHeight - container.scrollTop - container.clientHeight + // }); } }; @@ -93,12 +95,12 @@ const useAutoScrollToBottom = ( // Determine scroll direction const currentScrollTop = container.scrollTop; - setIsUserScrollingUp(currentScrollTop < lastScrollTop.current); + isUserScrollingUp = currentScrollTop < lastScrollTop.current; lastScrollTop.current = currentScrollTop; // Reset the scrolling flag after user stops scrolling scrollTimeout.current = setTimeout(() => { - setIsUserScrollingUp(false); + //setIsUserScrollingUp(false); }, 500); }; @@ -120,12 +122,33 @@ const useAutoScrollToBottom = ( clearTimeout(scrollTimeout.current); } }; - }, [isUserScrollingUp, smooth, threshold]); // Re-run when dependencies change or scrolling state changes + }, [smooth, threshold]); // Re-run when dependencies change or scrolling state changes return containerRef as RefObject; }; -export { - useAutoScrollToBottom +interface ScrollableProps { + children?: React.ReactNode; + sx?: SxProps, +} + +const Scrollable = ({ sx, children }: ScrollableProps) => { + const scrollRef = useAutoScrollToBottom(); + return {children}; +}; + +export { + useAutoScrollToBottom, + Scrollable, }; diff --git a/frontend/src/ResumeBuilder.tsx b/frontend/src/ResumeBuilder.tsx index 9cbf5dd..e316dbe 100644 --- a/frontend/src/ResumeBuilder.tsx +++ b/frontend/src/ResumeBuilder.tsx @@ -222,6 +222,7 @@ const ResumeBuilder: React.FC = ({ }, []); const renderJobDescriptionView = useCallback((small: boolean) => { + console.log('renderJobDescriptionView'); const jobDescriptionQuestions = [ @@ -456,22 +457,6 @@ const ResumeBuilder: React.FC = ({ // Render mobile view if (isMobile) { - /** - * Gets the appropriate content based on active tab - */ - const getActiveMobileContent = () => { - switch (activeTab) { - case 0: - return renderJobDescriptionView(true); - case 1: - return renderResumeView(true); - case 2: - return renderFactCheckView(true); - default: - return renderJobDescriptionView(true); - } - }; - return ( = ({ {/* Document display area */} - {getActiveMobileContent()} + {renderJobDescriptionView(true)} + {renderResumeView(true)} + {renderFactCheckView(true)} ); diff --git a/frontend/src/VectorVisualizer.tsx b/frontend/src/VectorVisualizer.tsx index 1ad5097..3fa185a 100644 --- a/frontend/src/VectorVisualizer.tsx +++ b/frontend/src/VectorVisualizer.tsx @@ -12,6 +12,8 @@ import Switch from '@mui/material/Switch'; import { SetSnackType } from './Snack'; +import './VectorVisualizer.css'; + interface Metadata { doc_type?: string; [key: string]: any; @@ -299,16 +301,30 @@ const VectorVisualizer: React.FC = ({ setSnack, rag, inli ); return ( - + { !inline && - + Similarity Visualization via Uniform Manifold Approximation and Projection (UMAP) } - } onChange={() => setView2D(!view2D)} label="3D" /> + } onChange={() => setView2D(!view2D)} label="3D" /> { const point = event.points[0]; @@ -323,7 +339,6 @@ const VectorVisualizer: React.FC = ({ setSnack, rag, inli content: `${emoji} ${type.toUpperCase()}\n${text}`, }); }} - data={[plotData.data]} useResizeHandler={true} config={{ @@ -333,7 +348,17 @@ const VectorVisualizer: React.FC = ({ setSnack, rag, inli showSendToCloud: false, staticPlot: false, }} - style={{ display: "flex", flexGrow: 1, justifyContent: 'center', alignItems: 'center', minHeight: '30vh', height: '30vh', padding: 0, margin: 0 }} + style={{ + display: "flex", + flexGrow: 1, + justifyContent: 'center', + alignItems: 'center', + minHeight: '240px', + padding: 0, + margin: 0, + width: "100%", + height: "100%", + }} layout={plotData.layout} /> {!inline && @@ -389,7 +414,7 @@ const VectorVisualizer: React.FC = ({ setSnack, rag, inli ); }; -export type { VectorVisualizerProps, ResultData, Metadata }; +export type { VectorVisualizerProps, ResultData }; export { VectorVisualizer